Skip to content

Cortisol, Melatonin, and the Sleep-Anxiety Cycle

How two hormones shape your nights—and what you can do when the cycle breaks down.

Need help right now? Open the Rescue Kit

Lumendal is an educational resource. Nothing here is medical or psychological advice. If symptoms persist, consult a qualified professional.

When to seek help

Quick answer: Cortisol and melatonin work in opposite rhythms to regulate your sleep-wake cycle. Cortisol normally rises in the morning to wake you and falls at night, while melatonin climbs after dark to help you sleep. When stress, anxiety, or disrupted routines push cortisol high at night, melatonin production may be suppressed, leaving you wired, alert, and unable to rest.

What cortisol and melatonin do in your body

Cortisol is often called the stress hormone, but it does far more than respond to emergencies. It helps regulate blood sugar, blood pressure, immune function, and your body’s internal clock. In a healthy rhythm, cortisol peaks within an hour of waking—a surge that helps you feel alert and ready to move. It then declines steadily through the day, reaching its lowest point around midnight.

Melatonin is produced by the pineal gland in your brain when light fades. It signals to every cell that night has arrived and it is time to prepare for rest. Melatonin does not force you to sleep, but it lowers body temperature, reduces alertness, and opens what researchers call the “sleep gate”—the window when falling asleep feels natural rather than effortful.

These two hormones work like a seesaw. When one is high, the other tends to be low. This opposition creates the rhythm that keeps you awake during the day and asleep at night.

The normal daily rhythm

In a well-regulated system, cortisol begins to rise two to three hours before you wake. This pre-dawn surge, called the cortisol awakening response, prepares your body for the day. Cortisol stays elevated through the morning, then slopes gently downward through the afternoon and evening.

Melatonin remains low all day. As the sun sets and your eyes register less light, the pineal gland begins to release melatonin. Levels climb steadily, peaking between 2 and 4 a.m., then fall again as morning approaches. This rise and fall is controlled by the suprachiasmatic nucleus, a cluster of cells in your brain that acts as your master clock.

When these rhythms stay synchronized, you feel alert when you need to be and sleepy when it is time to rest. But many factors can pull them out of alignment.

How stress and anxiety disrupt the cycle

When you feel anxious or threatened, your hypothalamus activates the HPA axis—a communication loop linking your brain, pituitary gland, and adrenal glands. The adrenal glands release cortisol, which mobilizes energy and sharpens focus. This response is useful during acute stress, but it becomes a problem when it fires at night or stays active for weeks.

Chronic stress keeps the HPA axis in a state of low-grade activation. Cortisol levels may stay elevated into the evening or spike in response to worry, noise, or a racing mind. High cortisol at night suppresses melatonin production, delays the sleep gate, and keeps your sympathetic nervous system—the branch responsible for alertness—switched on.

Many people lying awake at 2 a.m. are experiencing this collision: cortisol that should be low is high, melatonin that should be high is blunted, and the brain interprets the mismatch as a signal to stay vigilant. This is one biological root of cognitive arousal, the state where thoughts loop and multiply in the dark.

What happens when cortisol stays high at night

Elevated nighttime cortisol creates a cascade of effects. Your heart rate stays slightly faster. Your body temperature remains higher than it should be for sleep. Glucose is released into your bloodstream, giving you energy you do not need. Your brain stays in a state of readiness, scanning for problems and replaying the day.

This state feels like being wired and tired at the same time. You are exhausted, but your body will not let you rest. Some people describe it as feeling like their mind is racing while their body is heavy. Others notice physical tension—tight shoulders, clenched jaw, shallow breathing—that makes it hard to relax even when lying still.

Over time, this pattern can flatten your cortisol rhythm entirely. Instead of a clear peak in the morning and a trough at night, cortisol levels may stay moderate all day and all night, leaving you foggy in the morning and alert at bedtime.

If you wake at 3 a.m. with your heart pounding and your mind spinning, you are likely experiencing a cortisol spike. Your body is responding to a perceived threat—often a thought or worry—as if it were real and immediate.

How light, food, and routine influence both hormones

Your circadian rhythm depends on external cues called zeitgebers, German for “time-givers.” Light is the most powerful. Bright light in the morning suppresses melatonin and helps cortisol rise on schedule. Dim light in the evening allows melatonin to climb. Blue-wavelength light from screens, overhead bulbs, and streetlights can delay melatonin onset by two hours or more.

Food also acts as a zeitgeber. Eating late at night signals to your body that it is still daytime, which can raise cortisol and delay melatonin. Large meals close to bedtime increase core body temperature and digestion, both of which interfere with the drop in temperature your body needs to fall asleep.

Routine matters because your body learns patterns. Going to bed and waking at the same time every day—even on weekends—trains your HPA axis and pineal gland to anticipate the schedule. Irregular sleep times confuse the system, making it harder for cortisol to fall and melatonin to rise at the right moments.

How daily habits affect cortisol and melatonin
What you do Effect on cortisol Effect on melatonin Result for sleep
Bright light in the morning Supports healthy morning rise Suppresses daytime levels Strengthens rhythm, easier sleep onset
Screen time before bed May raise if content is stimulating Delays or suppresses release Later sleep onset, lighter sleep
Late, heavy meals Keeps levels elevated Delays rise Difficulty falling asleep
Irregular sleep schedule Flattens daily rhythm Unpredictable timing Insomnia, daytime fatigue
Consistent wake time Anchors morning peak Stabilizes evening rise More predictable sleep onset
Dim light after sunset Allows evening decline Permits natural rise Easier transition to sleep

Why anxiety and insomnia feed each other

Anxiety raises cortisol. High cortisol at night makes sleep difficult. Poor sleep increases anxiety the next day. This loop is one reason night anxiety can feel so stubborn. Each element reinforces the others.

When you lie awake worrying about not sleeping, your brain interprets that worry as a threat. The HPA axis responds by releasing more cortisol, which further suppresses melatonin and keeps you awake. The longer you lie there, the more your bed becomes associated with frustration and vigilance rather than rest. This learned association is why stimulus control—getting out of bed when you cannot sleep—can be so effective.

Breaking the cycle requires addressing both the physiological arousal and the mental patterns that sustain it. You cannot think your way out of high cortisol, but you can change the behaviors and environments that trigger it.

What you can do to support a healthier rhythm

Anchor your wake time

Set an alarm for the same time every morning, including weekends. This single habit trains your cortisol to peak on schedule, which in turn helps melatonin rise at the right time twelve to fourteen hours later. It may feel hard at first, especially after a poor night, but consistency is more powerful than any supplement.

Get bright light early

Spend ten to thirty minutes outside within an hour of waking, even on cloudy days. Outdoor light is far brighter than indoor lighting and sends a strong signal to your master clock. If you cannot go outside, sit near a window or consider a light therapy box designed for circadian support.

Dim your environment after sunset

Lower the lights in your home two to three hours before bed. Use lamps instead of overhead fixtures. If you use screens, enable night mode or wear blue-light-blocking glasses. The goal is not total darkness, but a gradual reduction in light intensity that allows melatonin to rise naturally.

Move your body during the day

Physical activity helps regulate cortisol and improves sleep quality, but timing matters. Morning or afternoon exercise supports a healthy rhythm. Intense exercise within two hours of bedtime can raise cortisol and body temperature, making it harder to fall asleep.

Eat earlier and lighter at night

Finish your last meal at least two to three hours before bed. If you need a snack, choose something small and low in sugar. Large, late meals keep your digestive system active and your cortisol elevated when both should be winding down.

Create a wind-down routine

Spend the last thirty to sixty minutes before bed doing something calm and predictable. Read, stretch, listen to quiet music, or practice progressive muscle relaxation. The routine itself becomes a cue that tells your body it is safe to lower cortisol and allow melatonin to rise.

Tonight, start here

  1. Set your alarm for the same time tomorrow. Even if you slept poorly tonight, wake at your target time. This anchors your rhythm.
  2. Get outside within an hour of waking. Ten minutes of daylight helps reset your cortisol peak and supports melatonin release twelve hours later.
  3. Dim your lights after dinner. Use lamps, candles, or low-wattage bulbs. Let your eyes register that the day is ending.
  4. If you cannot sleep after twenty minutes, get up. Sit in dim light and do something quiet until you feel sleepy again. This prevents your bed from becoming a place of frustration.
  5. Notice your breathing. Slow, deep breaths activate your parasympathetic nervous system, which lowers cortisol and signals safety to your body.
  6. Be patient with the process. Hormonal rhythms take days or weeks to shift. Small, consistent changes add up over time.

When to seek help

If you have been following these steps for several weeks and still cannot sleep, or if your sleep problems are new, severe, or accompanied by other symptoms—unexplained weight changes, persistent fatigue, mood swings, or physical pain—please contact a doctor. Some medical conditions, including thyroid disorders, sleep apnea, and mood disorders, can disrupt cortisol and melatonin rhythms and require professional evaluation. The “When to seek help” section on every page of this site offers additional guidance.

Where to go from here

Understanding cortisol and melatonin is one piece of the puzzle. To learn more about the mental side of nighttime wakefulness, read What Is Cognitive Arousal and Why Does It Peak at Night? If you want to retrain your brain’s association with your bed, explore Stimulus Control: Retraining Your Brain to Associate the Bed with Sleep. And for a broader look at what happens in your body and mind after dark, see The Science of Night Anxiety: What Research Actually Shows.

Go deeper

Frequently asked questions

Can melatonin supplements fix a disrupted cortisol rhythm?
Melatonin supplements may help you fall asleep faster, but they do not address the underlying cortisol dysregulation. They work best when combined with consistent sleep timing, light exposure, and stress management. Some people find them helpful for short-term use, but they are not a substitute for rebuilding a healthy rhythm through daily habits.
Why do I wake up at 3 a.m. with anxiety?
Waking at 3 a.m. often coincides with a natural dip in melatonin and a small cortisol pulse. If you are stressed or anxious, this pulse can be exaggerated, triggering full wakefulness and racing thoughts. Your brain interprets the cortisol surge as a signal that something is wrong, which fuels more worry and keeps you awake.
Does cortisol cause insomnia or does insomnia cause high cortisol?
Both. Chronic stress and anxiety raise cortisol, which disrupts sleep. Poor sleep then increases stress and keeps cortisol elevated the next day. This creates a feedback loop where each problem reinforces the other. Breaking the cycle requires addressing both sleep habits and the sources of stress.
How long does it take to reset cortisol and melatonin rhythms?
Most people notice some improvement within a few days of consistent wake times and light exposure, but full rhythm restoration can take two to six weeks. Your body needs time to recalibrate its internal clock. The key is consistency—irregular schedules or frequent all-nighters can undo progress quickly.
Can exercise at night raise cortisol and prevent sleep?
Intense exercise within two hours of bedtime can raise cortisol and body temperature, making it harder to fall asleep. Gentle movement like stretching, yoga, or a slow walk usually does not cause problems and may even help some people unwind. Pay attention to how your body responds and adjust timing accordingly.
What is the HPA axis and why does it matter for sleep?
The HPA axis is the communication pathway between your hypothalamus, pituitary gland, and adrenal glands. It controls your cortisol response to stress. When the HPA axis is overactive, cortisol stays elevated at night, suppressing melatonin and keeping you awake. Calming the HPA axis through routine, light exposure, and stress management helps restore normal sleep.
Does blue light really suppress melatonin?
Yes. Blue-wavelength light, which is abundant in screens and LED bulbs, signals to your brain that it is daytime. This suppresses melatonin production and can delay sleep onset by one to two hours. Dimming screens, using night mode, or wearing blue-light-blocking glasses in the evening may help reduce this effect.
Can I test my cortisol and melatonin levels at home?
Some at-home saliva or urine tests claim to measure cortisol and melatonin rhythms, but their accuracy and clinical usefulness vary. If you suspect a hormonal imbalance, talk to a doctor. They can order appropriate tests and interpret results in the context of your overall health and symptoms.

When to seek professional help

When to seek professional help. If racing thoughts at night are accompanied by persistent low mood, panic attacks, thoughts of self-harm, or if they interfere with your ability to function during the day for more than two weeks, please reach out to a qualified mental-health professional. You can also contact the 988 Suicide & Crisis Lifeline (call or text 988) in the U.S., or find your local crisis line at findahelpline.com.