What to Know About Leg Cramps: Causes, Treatment, and More

Medically Reviewed By Angela M. Bell, MD, FACP
Was this helpful?

Leg cramps occur when a muscle in the leg contracts, causing sudden pain. While the pain from cramps can be severe, leg cramps are often harmless and occur for benign reasons. However, sometimes these cramps can be a symptom of a chronic condition. Cramping in the legs can occur at any time, but many people experience nighttime leg cramps or cramps when they are resting.

Cramps in the legs, also sometimes called a charley horse, may feel like sudden pain that makes it difficult to move due to the involuntary contracting of the muscle. These cramps may cause soreness even after the cramping pain has initially subsided.

This article will discuss some possible causes of cramps in the legs and their treatments. It will also discuss when to consult a doctor for leg cramps and home remedies, as well as answer some frequently asked questions.

Causes of leg cramps

A woman places one leg forward and reaches to touch the ground to perform a leg stretch.
Nuria Seguí/Stocksy United

There are many things that can lead someone to develop leg cramps. Causes may include lifestyle factors as well as acute or chronic conditions.

Movement and posture

Low levels of physical activity may lead to leg cramps.

An older 2012 study notes that some clinicians believe that foot position can also trigger nighttime leg cramps. This is because if the foot is in plantar flexion — where the foot points or moves downward away from the leg — this can shorten the calf muscle and may possibly lead to cramping.

Muscle injury or fatigue

You may experience leg cramps due to muscle strain, fatigue, or overuse.

This can occur after overexerting the muscles during periods of physical activity.

Dehydration and electrolyte imbalance

Electrolytes are salts and minerals found in the blood. Examples include sodium, potassium, and magnesium.

If electrolyte levels become too low, it can cause muscle cramps and progress to more serious health complications.

Factors that may lead to low levels of electrolytes, and possible cramps, include:

  • dehydration
  • hot weather
  • illness
  • malnutrition
  • not replenishing electrolytes after dehydration

If you become dehydrated and lose electrolytes but only drink water to improve your hydration, this will not replenish your electrolyte levels.

Researchers from a 2019 study suggest that drinking only water after dehydration instead of rehydration solutions containing electrolytes made muscles more susceptible to electrically-induced cramps.

Learn more about electrolyte imbalance and its treatment here.

Vitamin deficiency

In addition to low levels of minerals, other nutritional deficiencies may lead to muscle pain or spasms.

For example, deficiencies in vitamin D and vitamin B12 can lead to leg spasms or cramps in some people.


Leg cramps during pregnancy can be common, especially in the third trimester.

While clinicians are not yet sure why they occur so often during pregnancy, some suggest it may be due to:

  • changes to metabolism
  • too much or too little exercise
  • electrolyte imbalances
  • vitamin deficiencies

Metabolic and hormonal conditions

Some conditions that affect the metabolic and hormonal processes of the body may also cause cramping.

Some of these conditions include:

  • Addison’s disease or adrenal insufficiency
  • thyroid diseases, such as Hoffmann’s syndrome and an underactive thyroid (hypothyroidism)
  • diabetes
  • metabolic myopathies, such as acid maltase deficiency and Forbes disease

Neurological conditions

Some neurological conditions, or conditions that affect the nerves and nervous system, can sometimes lead to muscle spasms or pain if they affect any nerves that coordinate muscle function.

Examples of neurological conditions include:

Cardiovascular disease

Conditions that affect the heart and vascular system can sometimes cause cramping in the legs. This is because impairments to blood flow and circulation can lead to local muscle pain.

Cardiovascular conditions that may lead to leg cramps or pain include peripheral arterial disease and conditions related to blood clots, such as deep vein thrombosis or embolism.

Additional causes

There are other factors that may contribute to the development of cramps or muscle pain. These include:

Other conditions which affect your mobility may also lead to leg cramps.

Sometimes, people can also experience cramps for an unknown reason.

Nighttime leg cramps

Researchers suggest that up to 60% of adults have reported having nighttime leg cramps. Having these cramps at night can lead to further effects on your health and quality of life due to disrupted sleep or even severe insomnia.

Factors and conditions that may lead to nighttime leg cramps include:

When to seek medical help

Although uncommon, leg cramps can sometimes appear as a symptom of a serious condition that may require urgent or intensive medical care.

Contact your doctor as soon as possible regarding any symptoms of leg cramps if you have an underlying health condition or for any persistent symptoms of cramping in the legs.

It is also advisable to see a doctor if you experience the following symptoms:

  • leg cramps that disturb your sleep
  • numbness or swelling in the legs
  • cramps lasting longer than 10 minutes
  • cramps alongside any other symptoms or health concerns

Seek emergency medical care or call 911 for the following symptoms alongside cramps or other health conditions:

  • swelling or warmth of the skin
  • discolored or blotchy skin
  • sudden breathlessness or difficulty breathing
  • chest pain
  • swollen veins that are hard or sore when touching them
  • changes in consciousness
  • fatigue
  • confusion or disorientation
  • dizziness
  • weak or rapid pulse
  • seizures
  • not urinating all day
  • very dark urine

Preventing cramps in the legs

Not all leg cramps may be preventable, but there are some steps you can take to reduce your chance of having cramps due to overusing the muscle and dehydration.

Prevention techniques include:

  • staying hydrated
  • eating a balanced diet
  • rehydrating after fluid loss with rehydration solutions
  • getting regular physical activity
  • stretching before and after exercise, and before bed
  • avoiding sitting still or being in the same position for too long

To help prevent nighttime leg cramps, avoid placing your feet in plantar flexion. You can do this by pointing your toes up if you are lying on your back or hanging your feet over the bed if you lie on your front.

Treatments for leg cramp relief

Treatment for persistent leg cramps will depend on the underlying cause. If you have an underlying condition, doctors will aim to improve condition management to relieve secondary symptoms like leg cramps.

For example, if your doctor suspects that your leg cramps are occurring as a side effect of a medication, they may work with you to change your dose or medication routine.

You may be able to relieve the pain of mild leg cramps with at-home care and remedies, such as stretching or massaging. Home care might include:

  • taking a bath with or without OTC Epsom salts (magnesium sulfate)
  • taking vitamin or mineral supplements if your doctor recommends it
  • drinking OTC rehydration solutions for dehydration
  • learning how to stretch and massage the muscles safely
  • applying a warm compress

Do not take any OTC supplements before consulting your doctor. All supplements may carry a risk of causing negative health effects, and safe dosages will depend on individual factors.

While some people suggest taking magnesium for leg cramps, there is limited scientific support showing any benefit. In fact, research in 2017 suggests that taking magnesium oxide for nighttime leg cramps does not produce any significant benefits over taking a placebo.

If at-home methods of care do not provide leg cramp relief, consult your doctor for advice.

How to stretch the leg muscles

You can stretch some of your leg muscles by holding stretching poses for 30–45 seconds and then relaxing. Repeat the stretches a few times for 5 minutes, stretching several times throughout the day, including before bed.

Stretches for leg cramps include:

Calf stretch

  1. Stand an arm’s length away from the wall.
  2. Keeping your feet flat on the floor, lean forward to press your hands against the wall until you feel a stretch in the lower part of your leg.
  3. Hold this for a few seconds and then relax.

Hamstring stretch

  1. Sit on the floor or in a chair with one leg stretched out straight in front of you.
  2. Keeping your back and knee straight, reach toward your feet with both hands.
  3. Hold this position for a few seconds. Then, repeat with the other leg.

Quadriceps stretch

  1. Lie down on your left side. Bend your right knee so that you can hold your right foot.
  2. Gently pull your leg toward your buttocks until you feel a stretch in your thigh, keeping your knees touching.
  3. Change sides to repeat on the other leg.


Angela M. Bell, MD, FACP, has reviewed the following frequently asked questions.

Do bananas help with leg cramps?

Some people claim that bananas may help with leg cramps as they contain potassium and other electrolytes and nutrients. However, there is limited scientific evidence supporting whether bananas can relieve cramps once they have started.

Additionally, some clinicians state that bananas will not prevent episodes of cramps. However, balanced nutrition is still important for maintaining health and avoiding painful symptoms.

How do I stop leg cramps immediately?

You may be able to relieve a cramp quickly by stretching and massaging the cramping muscle. Many cramps also go away on their own.

What is the best home remedy for leg cramps?

The best remedy for leg cramps will depend on the underlying cause.

For mild muscular cramps that occur due to the use of the muscle, rather than any underlying health conditions, stretching and massaging the leg may be an effective home remedy.

You can also take acetaminophen or ibuprofen to ease pain after leg cramps.

Can leg cramps be a sign of something serious?

While leg cramps are typically harmless, sometimes more serious conditions can lead to leg cramps.

Leg cramps can be a symptom of conditions that affect the nervous system, vascular system, and organs such as the heart or kidneys.

If you experience leg cramps regularly or have additional symptoms, contact your doctor for advice.


Leg cramps are a common occurrence and are typically harmless. Nighttime leg cramps or cramping during periods of rest are particularly common. They can occur due to mild or benign conditions such as muscle fatigue after exercising or pregnancy.

However, less commonly, cramps in the legs happen as a result of a more severe underlying condition.

You may be able to relieve mild or non-clinical cases of leg cramps with stretching, massages, and other at-home relief methods. Clinical causes of leg cramps may require medical treatment to resolve the underlying health condition.

Consult your doctor immediately for severe pain with cramps that does not improve or if you have symptoms such as discoloration of the skin, swelling, or disorientation.

Was this helpful?
Medical Reviewer: Angela M. Bell, MD, FACP
Last Review Date: 2022 Aug 19
View All Bones, Joints and Muscles Articles
THIS TOOL DOES NOT PROVIDE MEDICAL ADVICE. It is intended for informational purposes only. It is not a substitute for professional medical advice, diagnosis or treatment. Never ignore professional medical advice in seeking treatment because of something you have read on the site. If you think you may have a medical emergency, immediately call your doctor or dial 911.