You're in the shower. Out of nowhere, the chorus of a song you haven't heard in months starts playing in full stereo behind your eyes. You didn't summon it. You can't quite shut it off. Why do songs get stuck in your head like this? Welcome to one of the most common glitches in human cognition, a cousin of the way your brain insists on seeing faces in random patterns.

Your brain replays a song to scratch a mental itch

Songs get stuck in your head because catchy melodies set off a self-feeding loop in the brain's auditory and memory systems, an effect researchers call involuntary musical imagery, or INMI. The tune is usually a short fragment, and because your memory tends to hold onto unfinished things more stubbornly than finished ones, the brain keeps replaying it trying to resolve it. Certain songs are built to trigger this more than others: faster tempo, a simple up-and-down melodic shape, and one or two unusual leaps that make the tune stand out. It happens to roughly 90 percent of people at least once a week, and there's nothing wrong with you when it does.

The cognitive itch you can only scratch by humming

The marketing professor James Kellaris at the University of Cincinnati gave the phenomenon its most memorable metaphor in the early 2000s: a cognitive itch. Some tunes, he argued, irritate the mind the way an itch irritates skin, and the only way to scratch it is to mentally rehearse the tune, which makes the itch worse. Kellaris also found the experience is near universal, with women tending to report longer and more annoying episodes than men.

The fragment matters here. Most earworms aren't the whole song. They're a 15 to 30 second slice, usually the hook. And short, incomplete things are exactly what your memory clings to. This is the Zeigarnik effect, named for the Soviet psychologist Bluma Zeigarnik, who noticed waiters could recall unpaid orders perfectly but forgot them the moment the bill was settled. An unfinished melody is an open loop, and your brain hates open loops.

What makes one song stickier than another

In 2016, Kelly Jakubowski and colleagues published a study in Psychology of Aesthetics, Creativity, and the Arts that did something clever. They took 3,000 people's reports of their most common earworms and compared those tunes against matched songs that never got stuck, hunting for the musical fingerprint of a true earworm.

Three features stood out. Earworms have a faster tempo, something with a beat you'd move to. They follow a common global melodic shape, the gentle rise-then-fall arc you hear in nursery rhymes, which makes them easy for the brain to sing along to. And they break that simplicity with an unusual interval or repetition, a small surprise that sets the tune apart from the pack. Easy enough to replay, odd enough to notice. The songs people named most often were Lady Gaga's "Bad Romance," Kylie Minogue's "Can't Get You Out of My Head," and Journey's "Don't Stop Believin'."

So an earworm is a melody simple enough that your brain can run it on autopilot, with just enough quirk to flag it as worth running again.

The triggers that open the loop

Knowing what makes a song catchy doesn't explain why a specific tune ambushes you on a specific Tuesday. For that, look at Lassi Liikkanen and the team around Victoria Williamson, whose diary and survey work mapped the everyday circumstances that flip an earworm on.

They found a handful of reliable triggers. Recent and repeated exposure is the obvious one: hear a song a few times and it primes itself to replay. Then there are memory associations, where a word, a person, or a place yanks up a tune you've linked to it. Emotional states feed them too, both stress and happiness, a reminder of how strangely the brain handles strong feeling, like the way overwhelming cuteness can make you want to squeeze an adorable thing. And the sneakiest trigger is a wandering, low-attention mind. When you're doing something undemanding, like walking or showering, the brain has spare capacity, and an earworm rushes in to fill the silence.

You can chew an earworm into submission

Here's the wonder beat, and it's almost too simple to believe: you can interrupt an earworm by chewing gum.

In 2015, Philip Beaman and colleagues at the University of Reading ran three experiments published in the Quarterly Journal of Experimental Psychology, bluntly titled "Want to block earworms from conscious awareness? B(u)y gum!" People who chewed gum after being exposed to a catchy song reported significantly fewer involuntary replays of it. The reason ties back to how the brain "hears" silent music. Imagining a melody quietly engages the same articulatory machinery you'd use to actually sing it, part of a memory system called the phonological loop. Chewing gum occupies that machinery with a competing motion, jamming the signal before the tune can fully form. It's the cognitive equivalent of tapping your foot to throw off a heartbeat.

Gum isn't the only lever. Because earworms thrive on open loops and idle attention, two other tactics have support. Listening to the whole song through can close the Zeigarnik loop and let it go. And Beaman's work also points to engaging tasks of moderate difficulty, like a good anagram or an absorbing novel, that occupy your verbal working memory without overwhelming it. Too easy and your mind wanders back to the song. Too hard and you give up and the song returns. The sweet spot crowds the earworm out.

The strange comfort in all this is that an earworm is your memory working exactly as designed, a little too well. The same loop that traps "Don't Stop Believin'" is the one that lets you recall a phone number or a poem. Your brain is just rehearsing. It picked the song you'd least like to hear, and it isn't going to apologize.

Keep wondering: the looping mind also stages the strange theater of sleep, which is why we dream, conjures the eerie sense of a repeated moment behind what causes deja vu, and explains the odd reason why you can't tickle yourself.