Most people who hear music in their head at night are experiencing involuntary musical imagery, commonly called an earworm. The quiet of nighttime strips away competing sounds and mental distractions, giving those looping melodies more room to surface. Research from Baylor University has shown that the sleeping brain actually continues processing musical melodies, meaning earworms do not simply switch off when you close your eyes. In rarer cases, the experience crosses from a familiar internal replay into something that sounds genuinely external, and those situations can have distinct medical explanations worth understanding.
Why Nighttime Makes It Worse
During the day, your brain juggles a constant stream of sensory input: conversations, traffic sounds, the hum of appliances, your own active thinking. All of that competes for processing bandwidth and tends to crowd out the background chatter of involuntary thoughts. At night, especially once you are lying in a quiet room with your eyes closed, that competition drops away. The auditory system, still active and waiting for input, becomes more sensitive to internally generated signals. A tune that you barely noticed drifting through your mind during a busy afternoon can suddenly dominate your awareness when nothing else is vying for attention.
This is not a sign that something is wrong. The brain is always generating some level of spontaneous activity, and auditory cortex activity does not shut down just because external sounds have stopped. In fact, the transition from wakefulness to sleep involves a loosening of the usual top-down control your prefrontal cortex exerts over your thoughts. That loosening is part of why your mind tends to wander more freely as you drift off, and it is also why a catchy chorus can feel almost impossible to dismiss at bedtime.
Your Brain Keeps Playing Music While You Sleep
A particularly striking finding comes from a series of studies at Baylor University that directly tested whether music continues to loop in the brain during sleep. In a survey of about 200 people, those who frequently listened to music reported more persistent nighttime earworms, and those earworms were linked to worse sleep quality. A follow-up lab experiment randomly assigned 50 participants to listen to either lyrical or instrumental versions of popular songs before bed. Counterintuitively, the instrumental versions were the bigger problem: they increased the incidence of nighttime earworms and measurably worsened sleep quality as recorded by polysomnography, the gold-standard sleep measurement technique.
When participants woke during the night, they reported that earworms were playing in their heads at the moment of waking, which suggests the brain had been processing those melodies throughout sleep rather than simply picking them back up upon waking. Brain recordings backed this up, showing a significant increase in frontal slow oscillation activity, a marker associated with memory consolidation during sleep. In other words, the sleeping brain was actively rehearsing the music as part of the same memory-processing machinery it uses for other learned material.
1PubMed Central. Bedtime Music, Involuntary Musical Imagery, and SleepThe practical takeaway here is somewhat ironic for anyone who uses music as a sleep aid. Listening to catchy music close to bedtime, especially instrumental tracks, can actually seed the earworms that then disrupt your sleep. The researchers suggested that the very catchiness that makes a melody pleasant to fall asleep to is what makes it sticky enough to keep looping once you are asleep.
The Fuzzy Border Between Wakefulness and Sleep
Some people do not just get a tune stuck in their head at night. They hear music that sounds vivid and external, as though a radio were playing in the next room. If this happens right as you are falling asleep or just as you are waking up, the most likely explanation is a hypnagogic or hypnopompic hallucination. These are sensory experiences, often visual but sometimes auditory, that occur during the transition zones between wakefulness and sleep. They are remarkably common, experienced by a substantial portion of the general population at some point, and they are not considered a psychiatric symptom on their own.
The phenomenon has been recognized for centuries. A Dutch physician named Isbrand van Diemerbroeck documented detailed case histories in 1664 that described vivid sensory experiences occurring at the boundary of sleep, including the earliest known account linking these hallucinations to the supine sleeping position.2Wiley Online Library (Journal of Sleep Research). ‘The devil lay upon her and held her down’. Hypnagogic hallucinations and sleep paralysis described by the Dutch physician Isbrand van Diemerbroeck (1609-1674) in 1664 What makes these hallucinations distinctive is that they feel genuinely perceptual rather than imagined. You do not experience them the way you experience deliberately humming a song in your mind; they seem to arrive from outside you. This can be alarming if you do not know what is happening, but hypnagogic hallucinations are a normal byproduct of the brain’s somewhat messy process of transitioning between conscious states.
Auditory hallucinations have been classified by researchers along several dimensions, including their content, how vivid they seem, where they appear to come from, and their relationship to the sleep-wake cycle.3Cognitive and Behavioral Neurology. Auditory Hallucinations The sleep-transition variety sits in its own category, separate from hallucinations that occur during full wakefulness, because the mechanism is different. Your brain is essentially half-dreaming while still maintaining a thread of awareness, and the auditory cortex sometimes fires in patterns that produce recognizable musical fragments.
Musical Ear Syndrome and Hearing Loss
There is a specific condition, called musical ear syndrome, that deserves attention because it affects a population that might not expect it: people with hearing loss. When the auditory system receives less input than it is used to, the brain can compensate by generating its own sounds. The music people hear in these cases tends to be familiar songs, hymns, or patriotic tunes, and it often sounds genuinely external. Many people with musical ear syndrome initially check radios, televisions, and neighbors’ houses before realizing the source is internal.
The underlying mechanism appears to involve changes in brain excitability. Research on a patient with unilateral hearing loss found increased activity in the superior temporal gyrus, a brain region central to auditory processing. One proposed explanation centers on reduced levels of GABA, an inhibitory neurotransmitter. When GABAergic function drops, neurons that would normally be kept quiet can become hyperactive. That hyperactivity may be experienced as phantom sounds, including music. The same reduction in GABA function has also been linked to structural thinning of the auditory cortex over time, suggesting that the phantom perception and the underlying brain changes may reinforce each other.4PubMed Central. Musical Ear Syndrome in a Patient with Unilateral Hearing Loss: A Case Report
Musical ear syndrome tends to be worse at night for the same reason ordinary earworms are: quiet environments offer the least competition for the brain’s internally generated signals. People who hear phantom music during the day often notice it intensifies in the evening, when ambient noise drops. This is one reason the condition can be partially managed by introducing background sound, such as a fan or white noise, which gives the auditory system some real input to process instead of manufacturing its own.
The condition is not especially rare among older adults with significant hearing loss, though it remains underreported because people worry it signals dementia or psychosis. It does not. Musical ear syndrome is a perceptual phenomenon driven by sensory deprivation, not a psychiatric or cognitive disorder. That distinction matters, because a person who mentions it to a doctor unfamiliar with the condition may receive an unnecessary psychiatric referral.
Medical Conditions That Can Cause Musical Hallucinations
While earworms and hypnagogic experiences account for the vast majority of nighttime music perception, genuine musical hallucinations during full wakefulness do occur, and they can have medical causes that warrant evaluation. Musical hallucinations have been described in about 0.16% of a general hospital population, making them infrequent but not vanishingly rare.5PubMed Central. “Doctor, I Hear Music”: A Brief Review About Musical Hallucinations The causes span several categories.
Epilepsy can produce musical hallucinations in several distinct ways. Researchers have identified four subgroups of epilepsy-related musical hallucination: those that occur as auras before a seizure, those happening during a seizure, those arising between seizures, and those triggered by direct brain stimulation during surgical evaluation.6PubMed Central. Musical hallucinations and their relation with epilepsy If the music you hear is always the same fragment, comes on suddenly, and is accompanied by any unusual sensation like a strange smell, a feeling of déjà vu, or brief unresponsiveness, those features would warrant a neurological workup.
Certain medications and substance withdrawal can also trigger musical hallucinations. A review of drug-induced cases proposed that trigger drugs or alcohol withdrawal disrupt the balance of neurotransmitters in the brain’s auditory pathways, particularly in the temporal lobes, leading to the perception of music that is not there.7PubMed Central. Drug-induced musical hallucination This is worth considering if the experience started shortly after beginning a new medication or during a period of reducing alcohol intake.
Psychiatric conditions can produce auditory hallucinations as well, though these typically take the form of voices rather than music. In schizophrenia, for instance, impaired sensory gating has been documented: the brain fails to properly filter repetitive auditory stimuli, and this deficit correlates with the severity of hallucinations.8PubMed. Auditory verbal hallucinations in schizophrenia correlate with P50 gating But isolated musical hallucinations without other psychiatric symptoms are rarely a sign of schizophrenia or psychosis. The popular association between hearing things and “going crazy” is one of the most persistent and unhelpful misconceptions in this area, and it stops many people from mentioning the experience to their doctor.
How to Tell Whether Your Experience Is Normal
The distinction that matters most is between involuntary musical imagery and a true auditory hallucination. With an earworm, you know the music is in your head. It feels internal, like a memory replaying. You can sometimes change it by deliberately thinking of a different song, and it tends to come and go. With a true hallucination, the music sounds like it is coming from outside you, it may seem to have a specific location in the room, and you might initially look for the source. Hypnagogic hallucinations fall somewhere between these: they feel external but occur only in the narrow window around falling asleep or waking up, and most people learn to recognize them fairly quickly.
A few features should prompt a conversation with a doctor:
- Hearing loss: If you have noticed declining hearing and the music seems to come from outside your head, musical ear syndrome is a strong possibility and is treatable.
- New medication: If the music started within days or weeks of beginning a drug or changing a dose, mention it to your prescriber.
- Associated symptoms: If the music comes with unusual smells, visual disturbances, confusion, or brief episodes of lost awareness, a neurological evaluation is appropriate.
- Distress or interference: If the music is constant, loud, or distressing enough to interfere with daily life, that level of disruption warrants professional attention regardless of the cause.
For the majority of people, nighttime music is an earworm intensified by quiet and by the brain’s ongoing memory processing. It is annoying but benign.
Practical Ways to Quiet the Internal Soundtrack
Given what the research shows about how bedtime music seeds earworms, the most evidence-based intervention is also the simplest: stop listening to catchy music in the hour or two before bed. The Baylor studies found that instrumental music was more disruptive to sleep than lyrical versions of the same songs, likely because the brain has an easier time encoding and looping a pure melody without the additional complexity of words.1PubMed Central. Bedtime Music, Involuntary Musical Imagery, and Sleep If you use music to wind down, switching to a podcast, audiobook, or ambient soundscape may reduce the earworm problem without giving up the comfort of having something to listen to.
For musical ear syndrome related to hearing loss, the first step is usually addressing the hearing loss itself. Hearing aids restore external auditory input and give the brain less reason to generate its own. Background sound enrichment, whether through a fan, a sound machine, or open windows, also helps by keeping the auditory system occupied. Some clinicians have had success with cognitive behavioral approaches that reduce the distress associated with the hallucinations, even when the hallucinations themselves persist.
For ordinary earworms, a few informal strategies have anecdotal support. Engaging in a mildly absorbing verbal task, like doing a crossword or reading something engaging, can displace the musical loop by occupying the same cognitive resources the earworm needs. Some people find that listening to the stuck song all the way through to the end resolves the loop, as if the brain needs closure on the unfinished melody. Chewing gum has also been studied as an earworm interrupter, possibly because the jaw movements interfere with the subvocal rehearsal process the brain uses to maintain the melody.
The Role of Memory Replay in Nighttime Thought
The phenomenon of hearing music at night fits into a broader pattern of how the brain handles memories during rest. The hippocampus, a brain structure central to forming and retrieving memories, replays recent experiences during quiet periods and sleep. This replay is thought to be part of how memories are consolidated from short-term to long-term storage. Music, with its strong temporal structure and emotional associations, may be particularly prone to this kind of spontaneous replay.
A related line of research has proposed that inner speech itself, the internal monologue most people experience throughout the day, relies partly on this same episodic memory replay mechanism. The hippocampus spontaneously re-instantiates past experiences at rest, and this process may contribute not just to the verbal thoughts that run through your head but also to musical fragments, emotional memories, and other involuntary mental content that seems to emerge from nowhere when you are lying quietly.9ScienceDirect. The development and evolution of inner speech: Hippocampal contribution This framing suggests that nighttime earworms are not a glitch but a side effect of a memory system doing exactly what it is supposed to do, just at an inconvenient time.
The emotional weight of music may make it especially sticky in this process. Songs associated with strong emotions, whether positive or negative, tend to produce more persistent earworms than emotionally neutral melodies. At night, when prefrontal control loosens and the brain shifts into its default mode of internal processing, emotionally tagged memories get priority access. If the catchiest song you heard today also happened to play during a moment of strong feeling, it has a particularly good chance of resurfacing as you try to fall asleep. The brain is not trying to torment you. It is just doing its filing, and that particular file happens to have a very catchy soundtrack.