A foot cramp can strike out of nowhere, waking you from a sound sleep. You may suddenly feel the muscles tighten or knot up from a few seconds to a few minutes at a time.

Up to 60 percent of adults report getting nocturnal foot cramps. Spasms may happen just once in the night or result in repeat episodes that lead to insomnia and lingering pain.

The good news is that these cramps aren’t usually a reason for concern. While they can be associated with certain medical conditions, like diabetes or hypothyroidism, stretches and lifestyle changes may help ease them or make them go away entirely.

Keep reading to learn about the potential causes of nighttime foot cramps and how to get relief.

Sitting for long periods of time or otherwise being inactive may make the muscles in your feet more apt to cramp at night.

Sitting with poor posture may also inhibit blood flow to your feet or lead to nerve compression — two risk factors for developing cramps.

Your sleep position may also be a factor in circulation and nerve issues. Consider the following:

  • Try examining how you sleep to see if it might be contributing to nighttime cramping.
  • Sleeping with your feet pointing downwards may contribute to poor circulation.
  • Try sleeping on your back or side with a pillow underneath your knees.

Working the muscles in your feet too hard may make them vulnerable to cramping.

The muscle fibers in your feet continually contract and expand to allow movement. If you do too much of an activity too soon, or work your feet too strenuously, you may experience fatigue in your muscles.

Fatigue depletes your body of oxygen and allows waste products to build up throughout the day. This buildup can cause cramping and spasms at night.

Wearing poorly fitted shoes or shoes without enough support throughout the day may tax foot muscles as well. Standing or working on concrete floors or other hard surfaces can have a similar effect.

The foot muscles work extra hard to support the weight of your body. Improper footwear may also impair the foot’s circulation, cutting off blood and oxygen, and producing painful spasms even when you’re off your feet.

Another possible cause of foot cramps at night is dehydration. You may not be drinking enough water during the day, or a bout of diarrhea or other illness may be dehydrating you.

Even exercising in hot weather can dehydrate you quickly, draining your body of precious fluids, salts, and minerals, such as potassium, magnesium, and calcium.

When your body gets low in fluids and electrolytes, your muscles become more vulnerable to spasms and cramps. You continue sweating and losing fluids while you sleep. This is why your foot cramps may arise at night.

Deficiencies in vitamins B-12, thiamin, folate, and other B vitamins may lead to nerve damage.

Magnesium and potassium deficiencies may lead to leg and foot cramps.

If you suspect you may have a nutritional deficiency, talk with a doctor or medical professional. A simple blood test can reveal your levels and indicate to your doctor if you need any supplementation or other treatment for underlying conditions.

Note that taking too many supplements may actually cause more harm than good, so see a doctor and get tested before adding supplements to your diet.

Drinking too much alcohol may lead to nerve damage and a condition known as alcoholic neuropathy. Symptoms include anything from muscle cramping and weakness to numbness and tingling in the arms or legs.

Heavy alcohol use may also contribute to dehydration and nutritional deficiencies in important B vitamins.

Just as with other nutritional deficiencies, lacking these vitamins may impair nerve function, which may worsen symptoms like muscle spasms.

People who are pregnant are more susceptible to leg and foot cramping at night, particularly in the second and third trimesters.

Researchers don’t know exactly why. Possible reasons may include:

  • extra weight on the feet as baby grows
  • dehydration
  • nutritional deficiencies, particularly in magnesium

Medical conditions associated with nighttime foot cramping include:

Certain medications may also make you more susceptible to cramping. These include:

If you’re on dialysis, this can also make you more prone to cramping.

There are no specific treatments doctors recommend to treat overnight foot cramping. Instead, it’s best to treat its underlying cause.

If you exercise regularly, keep it up! Regular movement may help prevent leg and foot cramps in the day and night.

New to exercise? Speak with a doctor or medical professional for recommendations on a plan that may work for you. Try brisk walks around your neighborhood (wearing supportive shoes) or other low-impact activities to start.

Anecdotal evidence from a 2012 study suggests that a few minutes on an exercise bike or treadmill before bed may help with nocturnal leg and foot cramps.

Stretch and soothe your muscles

Be sure to stretch each day to keep foot muscles loose, especially before and after you get in a sweat session.

What if you’re having a cramp at night? Stretch your foot gently, but forcefully to relieve the cramp by flexing your foot and pressing down on your big toe.

Walking around and jiggling your leg may also help with both foot and leg cramps. Taking a warm bath or shower, or using ice may ease any lingering pain. Deep tissue massage may help in the long term.

Examine your shoes

Wear supportive shoes that are comfortable, especially if you walk a lot on hard surfaces.

The part of your shoes that help nest your heel in place is called a heel counter. Shoes with a firm heel counter may be better in terms of providing support throughout the day. Well-fitted, well-supporting shoes may also help you avoid nocturnal foot cramps.

If you’re having trouble or don’t find any comfortable shoes, your doctor may refer you to a podiatrist for custom inserts.

Drink more water

Experts recommend that men drink 15.5 cups and women drink 11.5 cups of fluids like water each day. Keeping your muscles hydrated can help prevent cramping.

A good rule of thumb is that your urine should be light yellow to clear. If it’s darker than that, consider drinking another glass of water.

People who are pregnant or breastfeeding may need additional fluid each day to meet their hydration needs. Speak with a doctor if you have concerns about hydrating your body.

Eat well and supplement

Eat a well-balanced diet that includes plenty of calcium, potassium, and magnesium. If you have a diagnosed deficiency, address it with your doctor’s supervision.

There are multiple studies that support magnesium supplementation as a means to help with cramping. Ask your doctor about dosage and brand suggestions. Supplements are available in your local grocery store, health food store, or online.

Foods rich in magnesium include:

  • whole grains
  • beans
  • nuts
  • seeds
  • unsweetened dried fruits

Bananas and leafy greens may also help balance electrolytes.

Lower your alcohol intake

Limit alcoholic beverages, like beer, wine, and mixed drinks. These beverages can dehydrate you.

In the case of alcohol-related nerve damage, seek help if you’re having a hard time quitting drinking. Consider reaching out to your doctor, a friend, or a local support program.

Conditions like alcoholic neuropathy can lead to permanent and progressive nerve damage. Early treatment is key in preventing this.

Practice self-care

You may be able to prevent nocturnal foot cramping with some simple self-care practices:

  • Untuck the covers from the foot of your bed before you go to sleep so that your feet aren’t confined.
  • Take a warm bath before bedtime to relax your muscles.
  • Practice some light stretching throughout the day so that your muscles aren’t tight before bed.

Essential oils

You may also want to try massaging some topical essential oils onto your feet before bed. Oils such as geranium, chamomile, coriander, and ylang-ylang oils have anti-spasmodic properties.

Aromatherapy with lavender or mint scents may also provide a calming sleep environment, which could decrease cramping.

During pregnancy

Let your doctor know if you’re experiencing nighttime foot cramping (or any severe muscle cramping) during pregnancy. While many of the same self-care measures may help you, your doctor can provide additional guidance.

Stretch your foot when a cramp strikes and elevate your legs to keep cramps at bay. Staying active, getting a massage, and taking a warm (not hot) shower or bath may also help.

Remember to take your prenatal vitamins each day to prevent nutritional deficiencies. Your doctor may recommend a magnesium supplement if the cramping is keeping you from sleeping.

You may find that the cramps go away on their own after you deliver your baby.

Foot cramps tend to go away on their own with home treatment, such as stretching or lifestyle changes, like drinking more water.

Talk with a doctor or medical professional if your cramps are causing severe discomfort, or if you notice any swelling, redness, or other changes to the foot or surrounding structures.

You may also want to make an appointment if the cramps are happening frequently and don’t improve with changes to your routine.