Leg cramps at night, muscle twitching and shaky hands: is it magnesium?
Night leg cramps, muscle twitching and shaky hands are common and usually harmless. What causes them, what magnesium and vitamins can and can't do, what helps tonight and when to worry.

Short answer
Night leg cramps are very common, especially after 50 and in late pregnancy, and most of the time they have no single cause. The usual contributors are age, muscle fatigue after exercise or long standing, dehydration, and medicines such as diuretics and statins (1). Magnesium is the supplement most people reach for, but a Cochrane review found it is unlikely to prevent ordinary night cramps in older adults, and the evidence in pregnancy is conflicting (2). Magnesium makes sense mainly if you have a reason to be low: long-term diuretics or acid-reducing medicines, a gut condition, diabetes or heavy alcohol use (3).
Muscle twitching and eyelid twitching are almost always harmless and are usually linked to stress, tiredness, caffeine and alcohol (4). Shaky hands are most often caused by stress, caffeine, temperature or age rather than a vitamin shortfall (5). Restless legs are different: an urge to move the legs in the evening, which is linked to low iron and is worth a ferritin test (6).
Being woken by a cramp or lying awake with twitching legs is not something you are imagining, and it is not your fault for "not stretching enough". It is common, it is disruptive, and there are practical steps that help.
Note: this article is for general education and is not medical advice. See a doctor for cramps with leg swelling, numbness or weakness, twitching with weakness or muscle wasting, or a new tremor.
What a night leg cramp actually is
A night leg cramp is a sudden, painful, involuntary tightening of a muscle, usually in the calf, sometimes in the foot or thigh. It typically lasts from a few seconds to several minutes, and the muscle can stay sore for hours afterwards. Cramps often happen when the calf is shortened with the foot pointed down, a common position in bed.
The exact mechanism is not fully understood. The leading explanation is that tired muscles and the nerves that control them become over-excitable, so a muscle that is already shortened fires uncontrollably. This explains why cramps follow unusual exercise, long periods of standing and positions that keep the calf short, and why stretching helps stop one.
What causes leg cramps at night
What causes leg cramps at night? In most people, no single cause is found. The NHS lists these common contributors (1):
Ageing. Cramps become more common with age, partly due to muscle loss and changes in nerves.
Muscle strain from exercise, especially new or unusually long activity, and worse in hot or humid weather.
Late pregnancy.
Medicines, including statins and diuretics; others linked to cramps include some asthma inhalers (beta-agonists) and some blood pressure medicines.
Dehydration from not drinking enough.
Liver disease related to heavy alcohol use.
Other medical conditions associated with cramps include diabetes with nerve damage, narrowed leg arteries (peripheral arterial disease), kidney disease, thyroid problems and nerve problems in the spine. A doctor will look for these if cramps are frequent, severe or come with other symptoms.
Leg cramps at night are "a classic sign" of what? Online lists often claim cramps are a classic sign of a particular deficiency or disease. In reality, night cramps are a classic sign of being human after middle age. They become more meaningful as a clue when they come with something else, such as numbness, swelling, weakness, leg pain on walking, or a new medicine.
What deficiency causes leg cramps at night?
Low levels of magnesium, potassium or calcium can cause muscle cramps and spasms. But in people who eat a varied diet and do not have a medical reason to be low, these deficiencies are uncommon, and most night cramps happen with normal levels.
When an electrolyte problem is behind cramps, there is usually a reason:
Diuretics (water tablets) increase losses of potassium and magnesium.
Long-term proton pump inhibitors for reflux can lower magnesium (3).
Vomiting, diarrhoea, heavy sweating or a gut condition such as coeliac or Crohn's disease.
Heavy alcohol use.
Low vitamin D, which can lower blood calcium and cause muscle aches and spasms.
If cramps are frequent and one of these applies, a blood test for electrolytes, calcium, magnesium and kidney function is reasonable.
Does magnesium help leg cramps?
Magnesium for leg cramps is one of the most common self-treatments, and the evidence is disappointing for most people.
A Cochrane review of randomised trials concluded that magnesium is unlikely to provide clinically meaningful prevention of idiopathic leg cramps in older adults, based on moderate-quality evidence for cramp frequency. For pregnancy-associated cramps, the trials disagreed: one placebo-controlled trial found a benefit and another did not, so the evidence is conflicting (2).
That does not mean magnesium never helps anyone. It may help people who are genuinely low, such as those on long-term diuretics or acid-reducing medicines. But as a general fix for night cramps, it is not supported. If you try it, check with your doctor or pharmacist first if you take other medicines, because magnesium interacts with some antibiotics and osteoporosis medicines; keep supplement magnesium at or below 350 mg a day, avoid it if you have kidney disease, and stop if you notice no difference after four weeks (3).
Vitamins for leg cramps at night are marketed widely, including B-complex and vitamin E. Evidence for both comes from small, older trials, and high-dose B6 in B-complex products can cause nerve problems. There is no vitamin with strong evidence for preventing ordinary night cramps.
Quinine, once commonly prescribed for cramps, should not be used to treat or prevent night leg cramps in the US: MedlinePlus warns it has not been shown to be effective for this and may cause serious or life-threatening side effects, including severe bleeding problems, kidney damage and an irregular heartbeat (7). In the UK, a GP may still discuss it in limited cases (1). Tonic water contains too little quinine to help and should not be used as a remedy.
How to stop leg cramps at night
During a cramp:
Stretch the muscle. For a calf cramp, straighten your leg and pull your toes up towards your shin, or stand and lean forward with your weight on the cramping leg.
Massage the muscle firmly.
Walk around or jiggle the leg once you can.
Apply warmth afterwards if the muscle stays sore.
To prevent them:
Stretch your calves before bed for a few minutes. Evidence is mixed, but it is low-risk and helps some people.
Keep your feet from pointing down in bed: loosen tight bedcovers or sleep with a pillow under your knees if you sleep on your back.
Drink enough fluid through the day, especially after exercise or in heat.
Build up exercise gradually, rather than doing a big session after weeks of rest.
Review your medicines with your doctor or pharmacist if cramps started after a new medicine.
Limit alcohol, especially in the evening.
Pickle juice for leg cramps is popular among athletes. Small studies suggest it may shorten exercise cramps, possibly through a reflex triggered in the mouth and throat rather than by replacing salt. There is little evidence for night cramps, and it is very salty, which matters if you have high blood pressure.
When to worry about leg cramps at night
When to worry about leg cramps at night: the NHS advises seeing a doctor if cramps disturb your sleep, come with numbness or swelling in your legs, or last longer than 10 minutes (1). Also see a doctor if cramps:
started after a new medicine, especially a statin or diuretic;
come with muscle weakness or shrinking muscles;
come with leg pain when walking that eases with rest, which can be a sign of narrowed arteries.
Get medical help the same day for a painful, swollen, warm or red calf, which can be a blood clot (deep vein thrombosis), especially after a long journey, surgery or in pregnancy, and for muscle pain or weakness with dark, cola-coloured urine (8, 10). Call 911 if a painful, swollen calf comes with chest pain or breathlessness, or for sudden numbness or weakness in the face, arm or leg (especially on one side of the body) or sudden trouble speaking (8, 9).
Muscle twitching all over the body
Muscle twitching all over the body every day is a common and frightening search, often because people have read that twitching can be an early sign of motor neurone disease (ALS). Twitches on their own, without weakness, are almost always benign. They are often called benign fasciculations and are linked to (4):
stress and anxiety;
tiredness and short sleep;
caffeine and alcohol;
exercise;
some medicines.
Benign twitching can come and go for months, move around the body and get worse when you focus on it, which in turn raises anxiety. What matters for doctors is not the twitching itself but whether there is weakness, muscle wasting, difficulty swallowing or speaking, or stiffness.
The NHS advises seeing a GP if a twitch lasts longer than two weeks, affects more than one area of the body, or the area feels weak or stiff (4).
Body twitching while sleeping, especially a sudden jerk as you fall asleep, is usually a hypnic jerk, a normal event that becomes more frequent with stress, caffeine and irregular sleep. Repeated leg kicks through the night may be periodic limb movements, which are linked to restless legs and low iron.
Eye twitching: is it a vitamin deficiency?
Eye twitching vitamin deficiency is a common search, but eyelid twitching (myokymia) is almost always caused by tiredness, stress, caffeine, eye strain or dry eyes. It usually settles on its own within days to weeks. Magnesium deficiency can cause twitching, but it is rarely the reason in an otherwise healthy person. See a doctor if the twitch lasts more than two weeks, closes the eye completely, spreads to other parts of the face, or comes with drooping or weakness.
Restless legs: the one where iron really matters
Restless legs syndrome feels different from cramps: an uncomfortable urge to move the legs, often with crawling, tingling or aching feelings, that starts or gets worse in the evening and at rest, and eases when you move. It can make it very hard to fall asleep.
Restless legs are linked to iron levels in the brain, and iron-deficiency anaemia is one of the conditions associated with it. When blood iron is low, iron supplements may be recommended as part of treatment (6). Many specialists check ferritin in anyone with restless legs and consider iron when ferritin is low or low-normal.
Magnesium for restless legs is often suggested online, but evidence is limited and inconsistent. Testing iron is the more useful first step. Caffeine, alcohol, nicotine and some antidepressants and antihistamines can make restless legs worse.
Shaky hands: is it a deficiency?
Shaky hands deficiency searches usually come from a fine tremor that is new or noticeable. The NHS lists the common causes as getting older, stress, tiredness, anxiety, anger, caffeine, alcohol, smoking and being very hot or cold (5). Other causes include an overactive thyroid, low blood sugar, alcohol withdrawal and medicines such as some asthma inhalers, antidepressants and lithium.
Vitamin deficiencies are an uncommon cause. B12 deficiency can cause unsteadiness and nerve symptoms, and very low magnesium or calcium can cause tremor and spasms, but usually with other symptoms. A tremor that is new, getting worse, affects one side, or comes with stiffness or slowness needs a doctor's assessment.
Living with night cramps and twitching: the questions people ask next
Why do I get leg cramps at night but not during the day?
At night your calf muscles are often in a shortened position, with the foot pointing down under the covers, and you are not moving to interrupt the tightening. Muscles that worked hard during the day, from exercise, long standing or walking, may also be more easily triggered. Dehydration after a day without enough fluid and evening alcohol can add to it. Stretching before bed and loosening bedcovers help some people.
Can dehydration cause leg cramps at night?
Not drinking enough fluid is one of the causes listed by the NHS, and cramps are more common after exercise in hot or humid weather. That said, many people with night cramps are well hydrated, and drinking more does not stop all cramps. It is a reasonable first step if you sweat a lot, exercise in heat or drink little through the day.
Can statins cause leg cramps at night?
Yes, statins are among the medicines linked to muscle symptoms, including cramps and aches. If cramps started after beginning a statin, talk to your doctor rather than stopping it yourself. Options can include checking muscle enzymes, adjusting the dose or trying a different statin. Muscle pain or weakness with dark, cola-coloured urine needs medical help the same day.
Are leg cramps in pregnancy a sign of a deficiency?
Leg cramps are common in late pregnancy and are not necessarily a sign of a deficiency. Studies of magnesium for pregnancy cramps have given conflicting results. Stretching, gentle activity and staying hydrated can help. Talk to your midwife or doctor before taking supplements, and get medical help the same day for a painful, swollen, warm or red calf, which can be a blood clot.
Should I be worried about twitching all over my body?
Twitching on its own, without weakness, is very common and usually harmless, especially with stress, short sleep, caffeine or exercise. It often comes and goes and moves around the body. See a doctor if a twitch lasts more than two weeks, affects several areas, or if you notice weakness, muscle wasting, stiffness, or difficulty swallowing or speaking.
Does potassium help with leg cramps?
Potassium helps only if you are low, for example because of diuretics, vomiting or diarrhoea. Most people with night cramps have normal potassium. According to the NIH, kidney disease and some blood pressure medicines (ACE inhibitors, ARBs and potassium-sparing diuretics) can make potassium build up to dangerous levels, so potassium supplements should only be taken on medical advice. Foods such as bananas, potatoes, beans and leafy greens are a safe way to keep intake up.
Before you blame yourself
People with night cramps are often told to "just stretch more" or "drink more water", and feel responsible when the cramps come back anyway. Many cramps have no single cause and simply become more frequent with age, pregnancy, certain medicines and tired muscles. That is not carelessness.
What helps is looking at what came before the bad nights: a long day on your feet, a new workout, a hot day, an evening drink, a change in medicine. Change one thing and see whether the next few weeks look different.
When to see a doctor
See a doctor if cramps disturb your sleep regularly, last longer than 10 minutes, come with numbness or swelling, began after a new medicine, or come with leg pain on walking. See a doctor for twitching that lasts more than two weeks or comes with weakness or stiffness, for restless legs that disrupt sleep, and for a new or worsening tremor.
Get medical help the same day for a painful, swollen, warm or red calf, which can be a blood clot (deep vein thrombosis), especially after a long journey, surgery or in pregnancy, and for muscle pain or weakness with dark, cola-coloured urine. Call 911 if a painful, swollen calf comes with chest pain or breathlessness, or for sudden numbness or weakness in the face, arm or leg (especially on one side of the body) or sudden trouble speaking.
How to bring this up with your doctor
What to ask for, by name. "Could we check electrolytes, calcium, magnesium, kidney function and vitamin D?" For restless legs: "Could we check ferritin?" If on a statin: "Could my cramps be related to my statin?"
What to bring. A list of all medicines and supplements with doses and when you started them, two to four weeks of notes on how often cramps or twitching happen, how long they last, and what you did that day: exercise, standing, heat, caffeine, alcohol.
What to say, out loud. "I've been woken by leg cramps [N] nights a week for [N] weeks. They last about [N] minutes. I'm taking [medicines]. Is there a cause we should look for?"
If you are told it's just age. Ask: "Are there any medicines I take that could contribute, and is there anything we should test to be sure?"
How long until you notice a difference? Most supplements take weeks, not days. See how long supplements take to work, and how to tell if one is working.


Start understanding your body
Learn what affects your energy, stress, sleep, and daily state. Get the app.
How Welltory helps — and what it cannot do
The limits first. Welltory is a general wellness product, not a medical device. It does not detect cramps, twitching or restless legs, measure electrolytes or diagnose any condition.
What it can do is help you see which days come before bad nights.
Sleep and night disturbance. Sleep Analysis uses Apple Watch or Oura data on iOS and syncs sleep from Samsung Health, Fitbit or Garmin Connect through Health Connect on Android (Sleep Analysis for Android). Broken nights show up in sleep stability and wake-ups, which you can match against nights you were woken by cramps.
Tag the day. On iOS with Apple Watch or Oura, when Welltory marks a stress or rest episode and asks "What happened?", tap, type or talk: "long walk", "standing all day", "hot day", "two coffees after 3 pm", "glass of wine", "started magnesium", "cramp at 3 am". Over weeks, My Patterns shows which tags tend to appear with stress and which with recovery; some sections need a paid plan.
Stress and recovery. Twitching and restless legs often get worse with stress and short sleep. On iOS with Apple Watch or Oura, Battery starts each morning from your resting heart rate on waking and your sleep (Today screen), so a run of low mornings and high-stress days is easy to spot.
A record for your doctor. From the web app you can export a CSV (Dashboard → choose a chart → Export) (export guide) to bring alongside your cramp notes and medicine list. Patterns are associations to discuss with your doctor, not proof of what causes your cramps.
How we made it
We based this article on NHS guidance on leg cramps, twitching, tremor and restless legs syndrome, the Cochrane review of magnesium for skeletal muscle cramps, the NIH Office of Dietary Supplements magnesium and potassium fact sheets, and MedlinePlus, NHS and CDC pages on quinine and urgent warning signs. Search questions came from what people in the United States most often ask about night cramps, twitching and shaky hands. For the product section, we checked every function against the Welltory Help Center on October 21, 2026.
Made with AI tools, then edited and fact-checked by the Welltory team. See our Editorial & AI policy.
Jane Smorodnikova, co-founder of Welltory, built the methodology behind how we read physiological data.
Written by Tatsiana Yashyna.


Discounts for blog readers: up to 36% off
See what affects your energy, stress, sleep, and daily state with Welltory
This article is for educational purposes only and is not medical advice. Supplements can interact with medicines and are not right for everyone; talk to your doctor or pharmacist before starting, stopping or combining them, especially if you are pregnant, breastfeeding, have kidney or liver disease or take prescription medicines. Get medical help the same day for a painful, swollen, warm or red calf, which can be a blood clot, or for muscle pain or weakness with dark, cola-coloured urine; call 911 if a painful, swollen calf comes with chest pain or breathlessness, or for sudden numbness or weakness in the face, arm or leg (especially on one side of the body) or sudden trouble speaking. Welltory is a general wellness product and does not diagnose, treat or prevent any condition. Sources were retrieved on October 21, 2026.
Was this helpful?
Ask AI for a summary of page
Written by Jane Smorodnikova
The founder and CEO of Welltory. A recognized tech leader with two Master's degrees and experience at MIT, she has scaled Welltory to over 17 million users.
Written by Tatsiana Yashyna
References
- NHS. Leg cramps. https://www.nhs.uk/conditions/leg-cramps/
- Garrison SR, Allan GM, Sekhon RK, et al. Magnesium for skeletal muscle cramps. Cochrane Database of Systematic Reviews 2012 (summary). https://nutrition-evidence.com/article/177742/magnesium-for-skeletal-muscle-cramps
- National Institutes of Health, Office of Dietary Supplements. Magnesium: fact sheet for health professionals. https://ods.od.nih.gov/factsheets/Magnesium-HealthProfessional/
- NHS. Twitching eyes and muscles. https://www.nhs.uk/conditions/twitching-eyes-and-muscles/
- NHS. Tremor or shaking hands. https://www.nhs.uk/conditions/tremor-or-shaking-hands/
- NHS. Restless legs syndrome. https://www.nhs.uk/conditions/restless-legs-syndrome/
- MedlinePlus (US National Library of Medicine). Quinine. https://medlineplus.gov/druginfo/meds/a682322.html
- NHS. Deep vein thrombosis (DVT). https://www.nhs.uk/conditions/deep-vein-thrombosis-dvt/
- Centers for Disease Control and Prevention. Signs and symptoms of stroke. https://www.cdc.gov/stroke/signs-symptoms/index.html
- MedlinePlus (US National Library of Medicine). Rhabdomyolysis. https://medlineplus.gov/ency/article/000473.htm
- National Institutes of Health, Office of Dietary Supplements. Potassium: fact sheet for health professionals. https://ods.od.nih.gov/factsheets/Potassium-HealthProfessional/




