Ever get a sudden, intense, throbbing headache, on both sides of your head, during or after a workout or race? You’re not crazy.

Ever get a sudden, intense, throbbing headache, on both sides of your head, during or after a workout or race? You’re not crazy—exercise really can cause some monster cranial pain. Here’s everything you need to know about exercise-induced headaches, and how to prevent them.

There are two kinds of exercise headaches, primary and secondary. One is painful but ultimately harmless. The other can be scary. No one is sure what causes primary exercise-induced headaches, which makes them frustrating. They most commonly come on after running, weight lifting or another hard, strenuous activity. Hot weather and training at a high altitude may contribute, and poor hydration could factor in as well. Determining the true cause of these headaches is sketchy because they seem so individual, but dilated blood vessels in and around your brain could contribute. This type of headache comes and goes and is treated like most headaches.

The secondary type of exercise-induced headache is caused by some underlying health problem, but even those vary widely. Bleeding in the membrane surrounding the brain, a problem with the blood vessels in the brain, a tumor or even a sinus infection could be the cause. How can you tell the difference between the two types?

Primaries give you a throbbing and even nasty headache, but that’s all. Secondaries deliver more serious symptoms along with the head pain: nausea, vomiting, dizziness, loss of consciousness, double vision or neck rigidity. Your risk of developing a primary headache rises if you train in hot weather or at a high altitude. If you’re prone to having migraines, you have a higher risk of getting exercise headaches, though they aren’t the same thing. Exercise headaches come on fast, like a thunderclap, and don’t last as long as migraines.

Fix It

Go over-the-counter. A common pain reliever like acetaminophen or ibuprofen can help with the pain, though some exercise headaches are brief and may be gone before the med kicks in. Take it only if you really need it.

Hydrate. At the first sign of pain, down a cup or two of water. This alleviated headaches in 65 percent of sufferers within 30 minutes, according to a study in the journal Headache. If you’ve been exercising, chances are you’re at least a little dehydrated.

Chill it. Putting a cold washcloth on your forehead or the back of your neck for 10 to 15 minutes may bring some relief. The chill may constrict dilated blood vessels.

Try acupressure or massage. There are two key points for reducing pain with acupressure: First, the web between your forefinger and thumb. Pinch the area and apply pressure in a circular motion (switch hands when you finish). Second, under the skull’s bottom edge on the back of the head, about halfway between the bony bumps just behind the ears and the middle of the skull; use your thumbs to apply pressure there in a circular motion. Work either area for 5 minutes, several times a day as needed.

Eat a pencil. Well, not eat, exactly. Put a pen or pencil between your teeth, but don’t bite. Leave it there for 5 minutes. This relaxes your jaw muscles, which could be tensed up.

Prevent It

Try to predict when they’ll hit. Some exercise headaches are predictable, occurring either under certain conditions—hot weather and high altitude are common triggers—or with a specific activity. You can either avoid these conditions or use medication prophylactically by taking a pain reliever an hour before your activity.

Warm up. Doing a proper warm-up before a hard workout can help as well. And by proper I don’t mean 5 minutes on a treadmill or a set of 10 bench presses with an empty barbell. A proper warm-up leaves you sweaty. A good 10-minute set of activation exercises will prepare your muscles for the work to come: Try forward and backward lunges with trunk rotation, side lunges, cariocas (sideways running with crossover steps), pogo hops, arm windmills, and inchworms (begin in the top push-up position, then walk your feet toward your hands as your butt rises in the air; at the top, walk your hands back out until you return to the push-up position). See below for other ideas for a proper warm-up.

When to Call a Doctor

If you experience a sudden, intense headache for the first time during or after a hard workout, see a doctor, especially if the pain is ongoing or worsens at night. Even if your headache lasts for only a few minutes or hours, it’s probably benign, but it’s best that your doctor hears about it and examines you.

Head to an ER immediately if you have secondary headache symptoms like nausea, vomiting, vision disturbances or neck rigidity. This could be a serious problem in or around your brain. Your doctor will want to do a CT scan or MRI to see what’s going on in your head. A prescription anti-inflammatory medication and perhaps a blood pressure medication could help. If your headaches are predictable, you can use the meds preventively.

Warm Up Right

Do 10 reps of each with no rest between sets.

Jumping Jacks
Stand with your feet together and your hands at your sides. Simultaneously raise your arms above your head and jump up just enough to spread your feet out wide. Without pause, quickly reverse the movement and repeat.

Walking High Knees
Stand tall with your feet shoulder-width apart. Without changing your posture, raise your right knee as high as you can and step forward. Repeat with your left leg. Continue to alternate back and forth.

Lunge With Side Bend
Stand tall with your arms hanging at your sides. Step forward with your right leg and lower your body until your right knee is bent at least 90 degrees. As you lunge, reach over your head with your left arm as you bend your torso to your right. Reach for the floor with your right hand. Return to the starting position. Complete the prescribed number of reps, then lunge with your left leg and bend to your left for the same number of reps.

Squat Thrusts (Dumbells Optional)
Stand with your feet shoulder-width apart and your arms at your sides. Push your hips back, bend your knees, and lower your body as deep as you can into a squat. As you squat down, place your hands on the floor in front of you, shifting your weight onto them. Kick your legs backward, so that you’re now in a push-up position. Quickly bring your legs back to the squat position. Stand up quickly and repeat the movement.