Foods to Eat and Avoid When You Have a Headache

Certain foods can help ease a headache by fighting inflammation, relaxing blood vessels, and replenishing nutrients your body may be low on. The best options are water-rich foods, magnesium-rich snacks, foods high in omega-3 fats, and ginger. Just as important: knowing which foods can make a headache worse so you can steer clear while you’re in pain.

Start With Water and Electrolytes

Dehydration is one of the most common and most fixable headache triggers. Even mild fluid loss can cause head pain, and the fix is straightforward: drink water. If you’ve been sweating, skipping meals, or drinking alcohol, plain water alone may not be enough because you’ve also lost electrolytes like sodium and potassium. A simple oral rehydration approach is to mix 8 teaspoons of sugar and half a teaspoon of salt into a liter of water. Coconut water, broth, or a banana alongside a glass of water can also help restore that balance quickly.

Don’t wait until you feel thirsty. If your headache started after exercise, a hot day, or a skipped meal, sip steadily over 30 to 60 minutes rather than gulping a full bottle at once.

Magnesium-Rich Foods

Magnesium plays a direct role in nerve signaling and blood vessel function, and low levels are strongly linked to headaches. Clinical trials using up to 600 mg of supplemental magnesium per day found modest reductions in migraine frequency, and the American Academy of Neurology considers magnesium therapy “probably effective” for migraine prevention. You don’t need a supplement to start getting more of it, though.

The best food sources, ranked by how much magnesium they pack per serving:

  • Pumpkin seeds (1 ounce, roasted): 156 mg
  • Chia seeds (1 ounce): 111 mg
  • Almonds (1 ounce): 80 mg
  • Spinach (½ cup, cooked): 78 mg
  • Cashews (1 ounce): 74 mg
  • Black beans (½ cup, cooked): 60 mg
  • Edamame (½ cup): 50 mg
  • Peanut butter (2 tablespoons): 49 mg

A handful of pumpkin seeds and a cup of cooked spinach together give you over 230 mg of magnesium, which is more than half of the daily value. If you’re in the middle of a headache, these won’t work as fast as a pain reliever, but building them into your regular diet can reduce how often headaches happen in the first place.

Ginger for Acute Pain

Ginger is one of the few foods with clinical evidence for relieving a headache that’s already started. In a randomized trial, 250 mg of ginger powder taken at the onset of a migraine reduced pain nearly as effectively as sumatriptan, a common prescription migraine drug. Both groups saw pain scores drop by about 4.6 to 4.7 points on a 10-point scale.

A quarter teaspoon of ground ginger is roughly 250 mg. You can stir it into hot water as a tea, grate fresh ginger into broth, or chew on a small piece of crystallized ginger. Taking it early, right when you first feel a headache building, appears to matter more than the exact amount.

Omega-3 Fats Over Omega-6 Fats

A 2021 randomized controlled trial published in The BMJ tested what happens when people with frequent migraines eat more omega-3 fatty acids (found in fish) and fewer omega-6 fatty acids (found in vegetable oils and processed foods). The results were striking. Participants who increased their omega-3 intake to about 1.5 grams per day while cutting omega-6 fats experienced four fewer headache days per month compared to the control group. They also logged nearly two fewer hours of head pain per day.

In practical terms, this means eating more salmon, sardines, mackerel, trout, and other fatty fish, while cutting back on foods fried in corn oil, soybean oil, and sunflower oil. Walnuts, flaxseeds, and hemp seeds also provide omega-3s, though in a form the body converts less efficiently than fish-based sources. If you’re dealing with frequent headaches, shifting this balance over a few weeks is one of the more evidence-backed dietary changes you can make.

Vitamin B2 for Prevention

Riboflavin, or vitamin B2, helps your cells produce energy, and people who get frequent migraines often have less efficient cellular energy production. A randomized trial in 55 adults found that 400 mg per day of riboflavin reduced migraine attacks by two per month compared to placebo. Both the American Academy of Neurology and the Canadian Headache Society recommend it for migraine prevention, noting that side effects are minimal (the main one being bright yellow urine).

The 400 mg therapeutic dose is far more than you’d get from food alone, since even the richest dietary source, beef liver, provides about 2.9 mg per serving. But regularly eating B2-rich foods still contributes to your baseline levels. Good sources include fortified cereals (1.3 mg per serving), oats (1.1 mg per cup), yogurt (0.6 mg per cup), milk (0.5 mg per cup), and almonds (0.3 mg per ounce). If your headaches are chronic, a B2 supplement may be worth discussing alongside these dietary changes.

Foods That Make Headaches Worse

What you avoid during a headache can matter as much as what you eat. Several categories of food contain compounds that actively trigger or worsen head pain in susceptible people.

Tyramine-Rich Foods

Tyramine is a natural compound that builds up as foods age or ferment. It causes nerve cells in the brain to release norepinephrine, a chemical that can trigger headaches when levels spike. The biggest offenders are aged cheeses (cheddar, blue cheese, Parmesan, Swiss, feta, Camembert), dry-cured meats like salami, fermented foods like kimchi, sauerkraut, and miso, and soy sauce. Tap beer, red wine, and vermouth are also high in tyramine. If you’re already in pain, skip these entirely.

Nitrate-Containing Processed Meats

Hot dogs, bacon, deli meats, and other cured or processed meats contain nitrates and nitrites as preservatives. Your body converts these into nitric oxide, a molecule that dilates blood vessels. For many headache sufferers, that vasodilation is exactly what triggers throbbing pain. Research from the American Gut Project found that migraine sufferers had higher levels of nitrate-processing bacteria in their mouths, which may explain why some people are more sensitive to these foods than others.

Histamine-Triggering Foods

Some people are sensitive to histamine in foods, which can cause flushing, head pain, and GI discomfort. There’s significant overlap with the tyramine list: aged cheeses, fermented foods, alcohol, processed meats, vinegar-based foods, and chocolate all tend to be high in histamine. Certain fruits like citrus, strawberries, and pineapple can also trigger symptoms in sensitive individuals. Leftovers that have been stored for more than a day or two accumulate histamine as bacteria break down proteins, so freshly prepared food is generally a safer bet during a headache.

A Simple Headache Meal

If you’re looking for something concrete to eat right now, here’s what a headache-friendly meal looks like: a piece of baked salmon with a side of cooked spinach, a handful of pumpkin seeds scattered on top, and a glass of water with a slice of fresh ginger steeped in it. That combination covers omega-3 fats, magnesium, hydration, and ginger’s pain-relieving properties, while avoiding every major trigger category. Brown rice (42 mg of magnesium per half cup) or a baked potato with the skin on rounds it out if you need something more filling.

For snacks, keep it simple: almonds, a banana, yogurt (plain, not aged), or peanut butter on whole grain toast. These are all low in trigger compounds and high in the nutrients that help your nervous system calm down.