MSD Manual

Please confirm that you are not located inside the Russian Federation

honeypot link

Muscle Cramps


Mark Freedman

, MD, MSc, University of Ottawa

Reviewed/Revised Oct 2023
Topic Resources

Causes of Muscle Cramps

The most common causes of muscle cramps are

  • Benign leg cramps that occur for no known reason, typically at night

  • Exercise-associated muscle cramping (cramping during or immediately after exercise)

Muscle cramps (also called charley horses) often occur in healthy people, usually in middle-aged and older adults but sometimes in younger people. Cramps tend to occur during or after vigorous exercise but sometimes occur during rest. Some people have painful leg cramps during sleep. Sleep-related leg cramps Sleep-related leg cramps Parasomnias are unusual behaviors that occur just before falling asleep, during sleep, or when waking up. (See also Overview of Sleep.) Various unconscious and largely unremembered behaviors... read more usually affect the calf and foot muscles, causing the foot and toes to curl downward. Although painful, these cramps are usually not serious and are thus called benign leg cramps.

Almost everyone has muscle cramps at some time, but certain conditions increase the risk and/or severity of cramps. They include the following:

Low electrolyte levels may result from use of some diuretics, an alcohol use disorder certain hormonal (endocrine) disorders, vitamin D deficiency Vitamin D Deficiency Vitamin D deficiency is most commonly caused by a lack of exposure to sunlight. Some disorders can also cause the deficiency. The most common cause is lack of exposure to sunlight, usually when... read more , or conditions that cause loss of fluids (and thus electrolytes). Electrolyte levels may become low late in pregnancy.

Cramps can occur shortly after dialysis Dialysis Dialysis is an artificial process for removing waste products and excess fluids from the body, a process that is needed when the kidneys are not functioning properly. There are a number of reasons... read more Dialysis , possibly because dialysis removes too much fluid from the body, removes the fluid too quickly, and/or lowers electrolyte levels.


Disorders that cause similar symptoms

Some disorders cause symptoms that resemble muscle cramps.

Dystonias Dystonias Dystonias are involuntary muscle contractions, which may be long-lasting (sustained) or come and go (intermittent). Dystonias may force people into abnormal positions—for example, causing the... read more are involuntary muscle contractions, but they usually last longer and occur more often than cramps. Also, they tend to affect other muscles and may affect many other muscles, including any limb muscles as well as those of the back, neck, and voice. In contrast, benign leg cramps and exercise-associated muscle cramping tend to affect the calf muscles.

Tetany is continuous or periodic spasms of muscles throughout the body. These spasms usually last much longer than muscle cramps and are more widespread. The muscles may also twitch.

Illusory muscle cramps occur in some people. These people feel as if they are having cramps but no muscle contraction occurs.

Peripheral arterial disease Overview of Peripheral Arterial Disease Peripheral arterial disease results in reduced blood flow in the arteries of the trunk, arms, and legs. Most often, doctors use the term peripheral arterial disease to describe poor circulation... read more Overview of Peripheral Arterial Disease (commonly called hardening of the arteries) in the legs may cause calf pain (claudication Symptoms Symptoms ) during physical activity such as walking. This pain is due to inadequate blood flow to muscles, not to muscle contraction as occurs with cramps.

Evaluation of Muscle Cramps

The following information can help people decide whether a doctor's evaluation is needed and help them know what to expect during the evaluation.

Warning signs

In people with muscle cramps, the following symptoms and characteristics are of particular concern:

If people have cramps in the arms or trunk or muscle twitching, the cause is more likely to be a disorder (such as an electrolyte or hormonal disorder) or a medication or drug than benign leg cramps or exercise-related muscle cramps.

When to see a doctor

People with muscle cramps should consult a doctor as soon as possible if they also have alcohol use disorder, sudden weakness or loss of sensation, or severe symptoms or if they have lost body fluids (for example, through vomiting, diarrhea, or excessive sweating). Otherwise, people should call their doctor to discuss how soon the doctor needs to see them.

What the doctor does

Doctors first ask questions about the person's symptoms and medical history Medical History in Neurologic Disorders Before doing a physical examination, doctors interview the person to obtain information about the person's current and past health (medical history). The history is the most important part of... read more and then does a physical examination. What doctors find during the history and physical examination often suggests a cause and the tests that may need to be done.

Doctors ask the person to describe the cramps, including the following:

  • When they occur

  • How long they last

  • How frequent they are

  • Where they are

  • Whether any event seems to trigger them

  • Whether any other symptoms are present

Doctors ask about symptoms that suggest clues to the cause:

  • Lack of menstrual periods or menstrual irregularities—symptoms that suggest pregnancy-related leg cramps

  • Vomiting, diarrhea, use of diuretics, excessive exercise, and sweating—symptoms that suggest loss of body fluids or electrolytes

  • Difficulty tolerating cold, weight gain, and coarse, thick skin—symptoms that may indicate hypothyroidism

  • Weakness, pain, or loss of sensation—symptoms that suggest a nerve disorder

The person is also asked about use of medications and alcohol, recent dialysis treatment, and any association between past dialysis treatments and muscle cramps.

Doctors also inspect the skin for signs of the following:

  • Alcohol use disorder (such as spider veins, red palms, and, in men, changes in the pattern of genital hair)

  • Hypothyroidism (such as a puffy face and loss of eyebrow hair)

  • Dehydration (such as less elastic skin)


No tests are routinely done. Instead, testing is done based on the history and results of the physical examination.

If cramping is widespread, particularly if reflexes are overactive, doctors measure levels of blood sugar and electrolytes (including calcium and magnesium) and do blood tests to check for kidney malfunction (which can cause levels of calcium and magnesium to be abnormal).

If the cramped muscles are also weak, electromyography Electromyography and Nerve Conduction Studies Diagnostic procedures may be needed to confirm a diagnosis suggested by the medical history and neurologic examination. Imaging tests commonly used to diagnose nervous system (neurologic) disorders... read more Electromyography and Nerve Conduction Studies may be done. For this test, a small needle is inserted into a muscle to record the electrical activity of the muscle when the muscle is at rest and when it is contracting.

Prevention of Muscle Cramps

Preventing cramps is the best approach. The following measures can help:

  • Not exercising immediately after eating

  • Gently stretching the muscles before exercising or going to bed

  • Drinking plenty of fluids (particularly sports beverages that contain potassium) after exercise

  • Not consuming caffeine (for example, in coffee or chocolate)

  • Not smoking

  • Avoiding stimulants, such as caffeine, nicotine, ephedrine, or pseudoephedrine (a decongestant contained in many products that do not require a prescription but are available only behind the pharmacy counter)

Stretching makes muscles and tendons more flexible and less likely to contract involuntarily. The runner's (gastrocnemius) stretch is the best stretch for preventing calf cramps. A person stands with one leg forward and bent at the knee and the other leg behind with the knee straight—a lunge position. The hands can be placed on the wall for balance. Both heels remain on the floor. The knee of the front leg is bent further until a stretch is felt along the back of the other leg. The greater the distance between the two feet and the more the front knee is bent, the greater the stretch. The stretch is held for 30 seconds and repeated 4 or 5 times. Then the set of stretches is repeated on the other side.

Standing Gastrocnemius Stretch

Did You Know...

  • Stretching helps prevent cramps because it makes muscles less likely to contract involuntarily (without the person's intending it).

Treatment of Muscle Cramps

If a disorder that can cause muscle cramps is identified, it is treated.

If a cramp occurs, stretching the affected muscle often relieves the cramp. For example, for a calf cramp, the person could use a hand to pull the foot and toes upward or could do the runner's stretch. Massage may temporarily relieve some types of cramps.

Most of the medications or supplements prescribed to prevent cramps from recurring (including calcium supplements, magnesium carbonate, and benzodiazepines such as diazepam) have not proved to be effective, and they can have side effects. Quinine is no longer recommended as treatment for muscle cramps because of its side effects, such as abnormal heart rhythms, vomiting, vision problems, ringing in the ears, and headaches. Mexiletine (used to treat abnormal heart rhythms) sometimes helps but also has many side effects, such as nausea, vomiting, tremors (rhythmic shaking of a body part), and seizures.

Key Points

  • Leg cramps are common.

  • The most common causes are benign leg cramps and exercise-associated cramping.

  • Stretching and not consuming caffeine can help prevent muscle cramps.

  • Medications are not usually recommended to prevent muscle cramps.

quiz link

Test your knowledge

Take a Quiz!