In this article
In the legs, cramps mainly affect the calf muscles, but also the sole of the foot and the thigh. When they occur during sleep or at rest, they are known as night cramps (nocturnal leg cramps). They are very common, become more frequent with age and can seriously disrupt sleep.
This article explains why cramps occur, the factors and conditions associated with them, how to distinguish them from other leg problems and the true role of laboratory tests, which is more limited than many people think. Test results should not be interpreted in isolation: the doctor who ordered them should read them alongside the patient's medical history. Reference values vary between laboratories and methods.
What happens in a muscle during a cramp
A cramp is caused by abnormal firing of the nerves that control the muscle. Instead of a controlled contraction, the fibres fire repeatedly and the muscle cannot relax. The most widely accepted theory is that cramps originate mainly in the peripheral nerve and spinal cord rather than the muscle itself. This explains why stretching the muscle, which stimulates tension receptors, usually stops the cramp.
Muscle fatigue appears to play an important role: a tired muscle is less able to suppress this firing. During sleep, pointed toes (with the foot extended), encouraged by the weight of the bedclothes, keep the calf muscles shortened. This helps explain why night cramps so often affect the calf.
| Feature | Typical cramp |
|---|---|
| Onset | Sudden, often at rest or during sleep |
| Location | Calf, sole of the foot, sometimes thigh |
| Duration | Seconds to a few minutes |
| Muscle | Hard and visibly contracted |
| Relief | Stretching the muscle |
| Afterwards | Residual pain that may last for hours |
Cramps with no identifiable cause: the most common type
A review published in a family medicine journal in 2012 reports that up to about 60% of adults say they have experienced night leg cramps and that, for most people, no specific cause is found. These are known as idiopathic cramps. They are more common from the age of 50, possibly because of loss of muscle mass, shortening of the tendons and reduced physical activity.
Having idiopathic cramps does not mean that you have a hidden illness. It means the risk factors are mainly part of daily life and that the principal measures involve stretching, regular physical activity and reviewing habits and medicines.
Everyday factors that encourage cramps
Intense or unfamiliar exercise, particularly in hot weather, is a known cause of exercise-associated cramps. Spending many hours sitting, standing still or with your legs crossed also encourages muscles to shorten. Many people notice more cramps after particularly active days or when wearing unsuitable footwear.
Dehydration and salt loss, such as during episodes of vomiting or diarrhoea or through heavy sweating, can trigger cramps. However, the role of water and salt intake alone in everyday cramps is less clear than is often claimed, and the scientific evidence is conflicting.
| Factor | Likely mechanism | Note |
|---|---|---|
| Intense or unfamiliar exertion | Muscle fatigue | More common in athletes and people who change their activity |
| Inactivity, many hours spent sitting | Shortened muscles | Common in older people |
| Pointed position of the feet in bed | Shortening of the calf muscles | Contributes to night cramps |
| Dehydration, vomiting, diarrhoea | Changes in fluid and salt levels | Mixed evidence for ordinary cramps |
| Heat | Sweating and salt loss | Mainly associated with exertion |
Pregnancy
Leg cramps are very common in pregnancy, especially during the second and third trimesters and at night. Suggested causes include changes in circulation, additional weight, changes in mineral metabolism and compression of nerves and blood vessels. For most pregnant women, cramps are uncomfortable but not dangerous and disappear after the birth.
Even so, a swollen, hot, red and painful leg during pregnancy should not be mistaken for cramp: pregnancy increases the risk of venous thrombosis, which requires a medical assessment that day. Any supplement taken during pregnancy, including magnesium or calcium, should be discussed with the doctor providing your care.
Conditions associated with cramps
Some conditions increase the frequency of cramps. The same 2012 review mentions peripheral vascular disease, lumbar spinal stenosis, cirrhosis, haemodialysis and pregnancy, among others. Diabetes, particularly when there is nerve damage (neuropathy), chronic kidney disease and hypothyroidism are also frequently mentioned.
Cramping can occur in amyotrophic lateral sclerosis and in other disorders affecting nerves outside the brain and spinal cord. It does not usually occur alone in these conditions. Other warning signs tend to include weakness, shrinking muscles or tiny movements that can be seen under the skin. If weakness develops alongside new cramps, seek a medical assessment.
| Condition or situation | Clues that may accompany the cramps |
|---|---|
| Peripheral arterial disease | Pain when walking that improves with rest |
| Lumbar spinal stenosis | Lower back pain, leg pain when walking and standing |
| Cirrhosis | Known liver disease, alcohol consumption |
| Chronic kidney disease, haemodialysis | Known kidney disease |
| Diabetes with neuropathy | Tingling, numbness in the feet |
| Hypothyroidism | Tiredness, feeling cold, dry skin, constipation |
| Neuromuscular diseases | Loss of strength, muscle wasting, fasciculations |
Medicines that may be involved
Several medicines have been associated with the onset of cramps. A 2012 study based on prescription data from a Canadian province found an association between starting some diuretics or long-acting inhaled bronchodilators (used for asthma and COPD) and the subsequent prescription of treatments for cramps; the association was weaker for statins. These data show an association and do not prove that the medicine causes cramps in any individual.
If you suspect that your cramps began after starting a new medicine, speak to the doctor who prescribed it. Never stop taking a prescription medicine on your own initiative: many of these medicines protect the heart, kidneys or lungs, and the doctor may adjust the dose or switch to another option.
The role of laboratory tests
Contrary to what many people expect, routine tests are not recommended for everyone with cramps. The 2012 review states that, for typical night cramps, the medical history and physical examination are usually enough and routine tests such as electrolyte tests are unnecessary. Tests become useful when the history or examination suggests a specific cause.
In these cases, depending on the circumstances, the doctor may request an electrolyte panel (sodium and potassium), calcium, magnesium, glucose, kidney function, liver function, TSH or CK (creatine kinase, an enzyme that rises when muscles are damaged). Ranges vary between laboratories and should be read on the report. A value just outside the range may not explain the cramps, and the doctor is responsible for interpreting it.
| Test | What it can help assess |
|---|---|
| Potassium and sodium | Salt imbalances, for example due to diuretics or vomiting |
| Calcium and magnesium | Mineral imbalances, for example due to certain medicines or conditions |
| Glucose, HbA1c | Diabetes |
| Creatinine | Kidney function |
| TSH | Thyroid function |
| CK | Muscle damage, for example associated with statins |
Cramps or something else?
Several leg problems can be mistaken for cramps. Restless legs syndrome causes an irresistible urge to move the legs, without a hard muscle contraction, and improves with movement. Claudication, which is typical of arterial disease, is pain when walking that forces you to stop. Neuropathy causes tingling, burning and numbness. Widespread muscle pain associated with medicines or muscle diseases does not have the sudden, localised nature of a cramp.
This distinction matters because the causes, tests and treatments are different. Describing the symptoms clearly to your doctor — when they occur, how long they last, whether the muscle hardens and what relieves them — is a great help in making a diagnosis.
How to prepare for the appointment
Before your appointment, it may help to record when the cramps occur, how long they last, which muscle is affected, what relieves them and what you did that day, over a period of two or three weeks. Also bring a complete list of medicines and supplements, including those bought without a prescription, and any previous test results you have.
| Information to bring | Why it helps |
|---|---|
| Cramp diary | Shows frequency, timing and possible triggers |
| List of medicines and start dates | Helps link cramps to new medicines |
| Known conditions | Points to kidney, liver, vascular or neurological causes |
| Previous test results | Avoids repetition and allows comparison |
Warning signs
Most cramps are harmless, but some signs warrant prompt assessment. A swollen, hot, red and painful leg, particularly on one side only, may indicate venous thrombosis and requires assessment that day. Severe and widespread muscle pain with weakness and dark urine, particularly in someone taking statins or who has undertaken extreme exertion, may indicate serious muscle damage.
Cramps accompanied by progressive weakness, loss of muscle mass, altered sensation or difficulty speaking or swallowing warrant a prompt medical appointment. If there is sudden shortness of breath, chest pain, severe palpitations or fainting, call 112.
At Clínica Alegre in Setúbal and Seixal, you can have laboratory tests and ask our team any questions about the results.
Frequently asked questions
Are cramps always caused by a lack of magnesium?
No. Most people are not found to have a deficiency, and studies of magnesium for ordinary cramps show little or no benefit.
Do I need tests because I have cramps?
Not always. Your doctor will decide based on your medical history and examination; tests are useful when a specific cause is suspected.
Can cramps be a sign of circulation problems?
They can be associated with vascular disease, but pain caused by poor arterial circulation occurs mainly when walking and improves when you stop.
Why do I get more cramps at night?
Rest, the pointed position of the feet and fatigue accumulated during the day are likely explanations.
Does drinking more water prevent cramps?
It may help if you are dehydrated, but the evidence for ordinary cramps is limited.
Do cramps become more common with age?
Yes, they become more common from the age of 50.
Did you enjoy this article?
Scientific references3
- Allen RE, Kirby KA. Nocturnal leg cramps. Am Fam Physician. 2012;86(4):350–5.
- Garrison SR, Dormuth CR, Morrow RL, et al. Night-time leg cramps and the prescription use preceding them: a sequence symmetry analysis. Arch Intern Med. 2012;172(2):120-6.
- Garrison SR, Korownyk CS, Kolber MR, et al. Magnesium for skeletal muscle cramps. Cochrane Database Syst Rev. 2020; 9(9):CD009402.





