Few things are as startling as a muscle cramp. One moment you are asleep, walking, or finishing a workout — the next, a muscle locks up in a hard, painful knot that refuses to let go. The pain can be intense, but in most cases it passes within a few minutes, leaving behind nothing more than a sore muscle and a few questions: why did that happen, and how do I stop it happening again?
Muscle cramps are extremely common. Research suggests that most adults experience them from time to time, and they become more frequent with age — some studies estimate that around half of adults over 50 report regular leg cramps. This guide explains what a cramp actually is, what tends to trigger one, what you can do in the moment, and which everyday habits may help reduce how often they occur.
What Is a Muscle Cramp?
A muscle cramp is a sudden, involuntary contraction of a muscle — or part of a muscle — that does not relax on its own. The muscle tightens, hardens, and often becomes visibly bunched up under the skin. It can last anywhere from a few seconds to several minutes, and the affected muscle may feel tender for hours afterwards.
Cramps can affect almost any muscle, but the most common sites are:
- Calves — by far the most frequent, especially at night
- Feet and toes — often after long walks or standing
- Thighs — front (quadriceps) or back (hamstrings)
- Hands and fingers — after repetitive gripping or writing
- Abdominal muscles — sometimes during exercise
Doctors often distinguish between two broad types. Exercise-associated cramps happen during or shortly after physical activity, often in the muscles being worked hardest. Nocturnal leg cramps strike at night, waking you from sleep — they are particularly common in older adults and in pregnant women, and they often involve the calf.
Importantly, a cramp is not the same as a muscle spasm that comes with an injury, and it is different from the stiffness you feel after a hard workout. A true cramp is sudden, sharp, and clearly localised to one muscle.
Why Do Muscles Cramp?
The exact mechanism of cramps is still not fully understood, but researchers believe several factors can make a muscle more likely to lock up. Often, more than one of these is at play at the same time.
Overuse and fatigue
The most common trigger is a muscle that has been worked hard or held in one position for too long. When a muscle is fatigued, the normal signals between the muscle and the nerves that control it can become disrupted. According to research published in sports medicine journals, fatigued muscles appear to lose some of their ability to relax properly — the nerves that tell a muscle to contract become overactive, while the nerves that tell it to relax become less responsive. The result is a contraction that will not switch off.
This is why cramps often appear near the end of a long run, during the last set of a workout, or after an unaccustomed bout of gardening, hiking or dancing.
Dehydration and electrolyte shifts
Muscles need the right balance of fluids and minerals — particularly sodium, potassium, calcium and magnesium — to contract and relax normally. Heavy sweating, a bout of vomiting or diarrhoea, or simply not drinking enough fluid on a hot day can disturb that balance.
It is worth noting that the evidence here is more nuanced than the old advice suggests. Research, including guidance from the US National Institutes of Health, indicates that plain dehydration alone does not always cause cramps, and that cramps can happen in well-hydrated athletes too. Still, fluid and mineral losses are recognised as a contributing factor, particularly in hot weather or during prolonged exercise.
Holding one position for too long
Sitting at a desk, standing in a queue, or lying in bed with the foot pointed can shorten a muscle and keep it in a cramped position. Night-time leg cramps often happen when the calf muscle is shortened — for example, when the foot rests in a pointed position under a heavy blanket. This may be one reason why gentle stretching before bed is often suggested as a preventive habit.
Ageing
As we get older, muscles naturally lose some mass and flexibility, tendons shorten slightly, and the nerves that control muscles change too. All of this may make cramps more likely. The US National Library of Medicine notes that nocturnal leg cramps become increasingly common after the age of 50, and many older adults experience them several times a month.
Pregnancy
Leg cramps are very common in the second and third trimesters of pregnancy. The reasons are not fully settled, but experts at the NHS suggest they may be linked to the extra weight the leg muscles carry, pressure on blood vessels, and changes in how the body handles minerals. Cramps in pregnancy are usually harmless, but any new or severe symptom in pregnancy should always be discussed with your doctor or midwife.
Certain medicines and health conditions
Some medicines — including certain diuretics (“water tablets”), some cholesterol-lowering statins, and some asthma medicines — list muscle cramps as a possible side effect. Health conditions that affect the nerves, circulation, liver or kidneys can also be associated with more frequent cramps. If your cramps started soon after a new medicine, or you have an ongoing health condition, that is worth mentioning to your doctor rather than trying to solve it alone.
What to Do When a Cramp Strikes
A cramp is painful, but the right response in the moment can shorten it considerably. The general principle is simple: gently lengthen the muscle and help it relax.
For a calf cramp:
- Straighten the leg and gently pull the toes up toward your shin, either with your hand or by pressing the foot flat against a wall or the floor.
- Stand up and put your weight on the affected leg if you can — walking a few steps often helps the muscle release.
- Massage the hard muscle firmly with your hands, using slow, circular movements.
For a foot cramp:
- Sit down, take hold of the foot, and gently stretch the toes and arch. Rolling the foot over a tennis ball or a cold water bottle may also help.
For a thigh cramp:
- If the front of the thigh cramps, stand and gently bend the knee, pulling the foot toward the buttock. If the back of the thigh cramps, sit and straighten the leg, leaning gently forward until you feel a mild stretch.
Heat or cold?
- A warm towel, a hot water bottle or a warm shower may help a tight muscle relax, and many people find heat soothing for the soreness that follows.
- A cold pack may help if the area feels inflamed or tender after the cramp releases. Wrap ice in a cloth and apply it for 10–15 minutes at a time.
Avoid forcing the stretch or bouncing — a slow, steady stretch is safer and usually more effective. If the cramp does not ease after several minutes of gentle stretching, or the pain is severe, seek medical advice.
Everyday Habits That May Help Prevent Cramps
There is no single guaranteed way to prevent cramps, but a few simple habits are associated with fewer episodes in many people.
Stretch regularly
Gentle stretching keeps muscles flexible and may reduce how often cramps occur, particularly at night. A short routine before bed is a popular approach:
- Calf stretch: Stand facing a wall, one foot forward and one back, and lean in until you feel a gentle stretch in the back calf. Hold for 20–30 seconds on each side.
- Hamstring stretch: Sit on the floor with one leg extended and reach gently toward your toes. Hold for 20–30 seconds on each side.
- Toe and foot stretch: Sit and gently pull each toe back, then curl them, a few times on each foot.
The American Academy of Orthopaedic Surgeons suggests stretching as part of general muscle care, and several small studies have found that a few minutes of calf stretching before bed may reduce the frequency of night cramps. Stretch slowly, breathe normally, and never stretch to the point of pain.
Stay hydrated
Drink fluids regularly through the day, and a little more in hot weather or when exercising. Water is enough for most everyday situations. During long, sweaty exercise — typically over an hour — a drink that replaces some of the salts lost in sweat may be more appropriate than water alone, according to guidance from sports medicine bodies such as the American College of Sports Medicine.
A practical tip: do not wait until you feel thirsty on a hot day. By the time thirst kicks in, you may already be mildly dehydrated.
Eat a varied, mineral-rich diet
Potassium, calcium and magnesium all play a role in normal muscle function, and a balanced diet is the best way to get them. Good everyday sources include:
- Potassium: bananas, potatoes, oranges, spinach, beans and yoghurt
- Calcium: milk, yoghurt, cheese, leafy greens and fortified foods
- Magnesium: nuts, seeds, whole grains, beans and dark leafy greens
There is no strong evidence that taking mineral supplements prevents cramps in people who already eat a balanced diet, and supplements can have side effects or interact with medicines. The US National Institutes of Health advises getting these nutrients from food first. If you think you may be deficient, talk to your doctor before starting any supplement.
Warm up and cool down
If you exercise, a gentle warm-up before activity and a slow cool-down afterwards may help your muscles cope better with the workload. Build up the intensity and duration of new activities gradually rather than jumping straight into a long, hard session — sudden, unaccustomed exertion is a classic cramp trigger.
Move regularly and change position
If you sit or stand for long periods, get up and move every 30–60 minutes. A short walk, a few ankle circles, or simply standing up and stretching the calves can keep muscles from staying shortened for too long. At night, try not to tuck heavy blankets tightly over the feet, which can hold them in a pointed position.
Keep muscles warm at night
Some people find that cold legs cramp more easily. Light, loose bed socks or a warm (not hot) environment may help if you notice your cramps are worse on cold nights.
Cramps in Athletes and Active People
If you exercise regularly, cramps are a familiar nuisance — and usually a sign that a muscle was pushed beyond its current conditioning rather than a sign of something serious. A few extra points apply:
- Pace yourself. Increase training load gradually — the commonly suggested rule is to raise distance or intensity by no more than about 10% per week.
- Replace what you sweat out. On long, hot workouts, plan fluid and salt replacement in advance rather than trying to catch up afterwards.
- Strengthen as well as stretch. Strong, well-conditioned muscles appear to cramp less often than weak or deconditioned ones. A balanced routine that includes strength work alongside flexibility may help over time.
- Do not ignore recurring cramps in the same muscle. A cramp that keeps returning in exactly the same place during the same activity may mean that muscle is weak, tight, or being overloaded — a physiotherapist or sports medicine doctor can help identify the cause.
When to See a Doctor
Most cramps are harmless and occasional. But see a doctor promptly if you notice any of the following:
- Cramps that happen very frequently, or that are getting worse over weeks
- Cramps that do not ease with stretching, or that leave the muscle swollen or very painful for more than a day
- Cramps together with muscle weakness, numbness, or tingling
- Cramps with swelling, redness, or skin changes over the muscle
- Cramps that started after you began a new medicine
- Cramps along with dark or cola-coloured urine after heavy exercise — seek urgent care, as this can be a sign of muscle breakdown
- Cramps with fever, vomiting or diarrhoea that are causing dehydration
- Leg cramps with swelling in one leg, especially if the leg is warm or red — seek urgent care
Also see a doctor if you have a long-term condition such as diabetes, kidney disease, liver disease or a thyroid disorder and your cramps are becoming more frequent. These conditions can affect muscle and nerve function, and cramps may be one of the signs that something needs attention.
Frequently Asked Questions
Why do I get cramps at night?
Night cramps are often linked to the calf muscle being held in a shortened, pointed-foot position during sleep, combined with age-related changes in muscle and nerve function. Gentle calf stretches before bed and keeping the feet from being pinned in a pointed position under heavy blankets may help reduce them.
Does eating a banana prevent cramps?
Bananas are a good source of potassium, which muscles need to function normally. However, there is no good evidence that eating a banana — or taking any single food — will prevent a cramp on its own. A varied diet that includes potassium-rich foods supports overall muscle health, but cramps usually have more than one cause.
Are cramps a sign of low magnesium?
Low magnesium can be associated with muscle cramps, but it is only one of many possible causes, and most people who get cramps do not have a magnesium deficiency. Blood tests can check magnesium levels if your doctor thinks it is worth investigating, and supplements should only be taken on medical advice.
Should I exercise through a cramp?
No. Stop the activity, gently stretch the muscle, and wait until the cramp fully releases and the soreness eases. Exercising through a cramp can strain the muscle and may make the cramp last longer. Once it has settled, you can usually resume gentle activity.
The Bottom Line
Muscle cramps are painful, but for most people they are occasional, harmless, and manageable. Understanding the common triggers — fatigue, prolonged positions, fluid and mineral losses, and ageing — helps you respond in the moment and build habits that may reduce how often they strike. Gentle stretching, staying hydrated, eating a varied diet, and building up exercise gradually are simple, practical steps that support healthy muscles at any age.
And when cramps become frequent, severe, or come with other symptoms, do not just put up with them. A doctor can check for underlying causes and help you find a plan that works for you.
Medical note: This article is for general information only and is not medical advice. Muscle cramps can have many causes, and only a proper medical assessment can identify the right approach for your situation. If cramps are frequent, severe, or accompanied by weakness, swelling or other worrying symptoms, please consult a qualified doctor.
Aman Kishor runs medicaal.in, where he publishes general health information for everyday readers. The content is general information only, not medical advice.