Written by the Nuvirox Research Team
Key points
- Eyelid twitching (myokymia) is caused by a single overactive nerve-muscle unit, and it's overwhelmingly benign — a 2023 primary-care study found no underlying neurologic disease in 94% of 352 patients with eye twitching.
- The classic triggers — caffeine, stress, fatigue, and screen time — all raise nervous-system excitability at exactly the moment your eyelid muscles are most active from a day of blinking, which is why it often surfaces as you're winding down.
- Twitching that spreads beyond the eyelid, closes the eye completely, or affects other parts of the face is the signal to see a doctor rather than wait it out.
Short answer: eye twitching right before sleep is almost always eyelid myokymia, a harmless, self-limited nerve misfire, and it's common precisely because bedtime is when your accumulated triggers — caffeine, screen time, fatigue — peak all at once. A single motor unit in the eyelid muscle fires on its own, producing a rhythmic flutter you can feel but that's rarely visible to anyone else. It has nothing to do with anything being wrong with your eye itself.
What's actually happening in the eyelid?
Eyelid myokymia comes from spontaneous, repetitive firing of a single motor unit within the orbicularis oculi, the ring of muscle that closes your eyelid. Electrophysiologically, that one unit discharges in bursts several times per second, independent of any voluntary movement you're making. The exact trigger for why a given motor unit starts misfiring isn't fully understood, but it reliably tracks with a handful of everyday factors: caffeine, alcohol, poor sleep, stress, and prolonged near-focus screen use, all of which raise the general excitability of your nervous system.
A 2024 study published in Cureus looked specifically at digital screen time, uncorrected vision problems, and blood electrolyte levels in people with eyelid twitching, and found associations across all three — supporting the idea that eye strain and mild electrolyte shifts both contribute, on top of the classic stress-and-caffeine picture.
Why does it show up specifically as you're falling asleep?
Bedtime is when the day's accumulated triggers are at their peak: hours of screen exposure are behind you, caffeine from earlier in the day may still be active in your system, fatigue is at its highest point, and your nervous system is transitioning between wake and sleep states — a period where various minor neuromuscular quirks tend to become more noticeable simply because you're lying still with nothing else to focus on. It's the same reason you notice your heartbeat or breathing more at night: less external distraction, more internal awareness.
What clears it up
Because caffeine and poor sleep are the two most consistently reported triggers, cutting back on afternoon and evening caffeine and getting more consistent sleep are the most evidence-aligned first steps. Reducing screen time in the hour before bed, or using the 20-20-20 rule during the day (every 20 minutes, look at something 20 feet away for 20 seconds) addresses the eye-strain contributor. Most episodes resolve within days to a couple of weeks without any specific treatment.
It's worth being specific about what "resolves on its own" looks like: myokymia tends to come in bouts — a few seconds to a couple of minutes of twitching, then it stops, then it may return later the same evening or the next night. That on-and-off pattern is normal and doesn't indicate the underlying trigger is getting worse; it's simply how a single misfiring motor unit behaves. What matters for tracking whether your changes are working is the overall trend across several nights, not whether it happens at all on any single night.
When to talk to a clinician
See an eye doctor if the twitching persists beyond several weeks despite lifestyle changes, spreads to involve the whole side of your face, causes your eyelid to fully close, or comes with any change in vision. Those patterns point away from ordinary myokymia and toward conditions like blepharospasm or hemifacial spasm, which need a different evaluation.
Frequently asked questions
Does magnesium deficiency cause eye twitching?
It's a commonly cited possible contributor, and magnesium is genuinely involved in nerve and muscle signaling, but true magnesium deficiency is uncommon in otherwise healthy adults, and it's just one of several overlapping possible triggers rather than the dominant cause for most people.
Is it bad that I can feel it but no one else can see it?
No — that's actually the expected pattern. Eyelid myokymia is usually a subtle, localized twitch that's far more noticeable to the person experiencing it than to anyone watching, since the movement is small.
Can dehydration cause eye twitching?
It's plausible as a minor contributor since fluid balance affects nerve excitability generally, but it's a much smaller factor than caffeine, sleep debt, and screen-related eye strain in the research on this.
How long is too long for an eye twitch to last?
Most benign episodes resolve within a few days to two weeks. Twitching that persists steadily beyond that window, especially if it's not improving with basic lifestyle changes, is a reasonable point to get it checked.
Does alcohol before bed make eye twitching more likely?
It can. Alcohol affects sleep quality even when it helps you fall asleep faster, and poor-quality sleep is one of the clearer triggers for myokymia, so an evening drink can indirectly contribute even though alcohol itself isn't the direct cause.
Can allergies cause eyelid twitching?
Allergies themselves don't directly cause myokymia, but eye rubbing from itchy, allergy-irritated eyes adds mechanical strain to the eyelid muscles, which can make an existing twitch more noticeable or persistent.
Does it matter which eye or eyelid is twitching?
Not particularly for benign myokymia, which can affect either the upper or lower lid of either eye and often switches sides or lids between episodes. A twitch that's always confined to exactly the same small area over a long period is still typically benign, but it's one more detail worth mentioning if you do see a doctor.
Related reading: Why Do You Sometimes Hear Your Name Called as You Fall Asleep and Why Do You Get Brain Zaps as You Fall Asleep.
FROM NUVIROX
Why we formulated Sleep+ Restore
Sleep+ Restore is our formula built around the wind-down side of the night: the part of the evening where your nervous system needs to shift out of alert mode before sleep can start. We're not going to list ingredients or dosages here — Sleep+ Restore is currently in reformulation, so any label specifics we printed today could be out of date by the time you read this.
What we can tell you is the philosophy behind it: a formula aimed at supporting a calmer transition into sleep, not a sedative that knocks you out. If what you're dealing with tonight is a specific, unusual, or medically relevant symptom rather than garden-variety trouble winding down, a supplement isn't the right tool for that — see a clinician instead. And every order carries our 60-day money-back guarantee, long enough to actually judge whether it's helping.
Learn more about Sleep+ Restore →The bottom line
An eyelid twitch that shows up as you're settling into bed is a well-documented, harmless nerve quirk — and bedtime is actually the most likely time to notice it, since that's when caffeine, screen exposure, and fatigue have all had the whole day to build up. Trimming afternoon caffeine and prioritizing consistent sleep are the two changes most likely to make it go away. Twitching that spreads to the rest of your face or won't quit after several weeks is the exception worth a doctor's visit.
References
- Gunes IB. "Association Between Eyelid Twitching and Digital Screen Time, Uncorrected Refractive Error, Intraocular Pressure, and Blood Electrolyte Imbalances." Cureus. 2024;16(9):e69249. doi: 10.7759/cureus.69249. PMCID: PMC11398718.
- "Eyelid Myokymia." StatPearls. NCBI Bookshelf. Updated 2023.
*These statements have not been evaluated by the Food and Drug Administration. This product is not intended to diagnose, treat, cure, or prevent any disease. This article is for informational purposes only and is not a substitute for professional medical advice.
