Charley horses, painful muscle spasms usually in the leg or foot, can happen to people of all ages and lifestyles. Worse yet, they can strike at any time of the day or night, though it\u2019s common to have muscle cramps while sleeping.\nFind a UPMC primary care physician by visiting the\u00a0UPMC Primary Care website\u00a0or by calling 1-855-676-UPMCPCP.\nAlthough they appear to happen randomly, some habits and conditions have been linked to charley horses, and there are steps you can take to prevent them.\nWhat Is a Charley Horse?\nA charley horse is another name for a muscle spasm, which is when a muscle contracts and will not relax. Muscle spasms can happen to any muscle in the body, but they are most common in the leg and foot. During a muscle spasm, the muscle becomes hard and tight and may be tender to the touch. After the spasm subsides, the muscle may be sore for hours or even days.\nCharley Horse Causes\nWhile there is no definite cause for charley horses, several factors make their occurrence more likely, including:\n\nDehydration\nExercising in very hot or cold temperatures\nOverusing the muscle\nStress\nPoor blood flow\/circulation\nNot getting enough vitamins\/minerals\nStanding or sitting too long without moving\nMalfunctioning nerves\nCertain medications\n\nHow to Treat Charley Horses\nMost of the time, muscle spasms resolve on their own. To help ease the pain when they happen, you can try one of the following:\n\nApply heat during the cramp and ice after it ends\nGently stretch the muscle\nMassage the muscle\n\nThe best treatment for charley horses is prevention. You can take steps to prevent them by:\n\nDrinking plenty of water\nStretching before and after exercise\nEating foods high in magnesium, potassium, and calcium\nWearing comfortable, supportive shoes\n\nIn some cases, repeated charley horses can be the result of nerve issues, which can be diagnosed with an MRI scan. If you experience muscle spasms frequently, they may be a symptom of an underlying health condition, and you should consult your doctor.