What to Eat for a Headache and Foods to Avoid

Certain foods can help relieve a headache or reduce how often you get them, mostly by addressing the underlying triggers: dehydration, low blood sugar, inflammation, and nutrient deficiencies. What you choose to eat (and avoid) during a headache matters more than most people realize, and a few dietary shifts can make a noticeable difference over weeks.

Water and Electrolytes Come First

Dehydration is one of the most common and overlooked headache triggers. Before reaching for food, start with fluids. Cleveland Clinic recommends six to eight glasses of water per day (roughly 1.5 to 2 liters) as a baseline. If you’ve been sweating, exercising, or drinking alcohol, you’re likely behind on both water and electrolytes.

A low-sugar sports drink or coconut water can help replace lost sodium and potassium, which your body needs to maintain fluid balance. Plain water works for mild cases, but if your headache hits after physical activity or a hot day, adding electrolytes speeds recovery. Watermelon, cucumbers, oranges, and strawberries are all high-water-content foods that pull double duty.

Foods That Stabilize Blood Sugar

Skipping meals or eating sugary snacks causes your blood sugar to spike and then crash, and that crash is a reliable headache trigger. The fix is eating foods that release energy slowly, keeping your blood sugar steady instead of sending it on a roller coaster.

Low glycemic index foods (rated 55 or below) are your best options here: most fruits and vegetables, beans, nuts, minimally processed whole grains, pasta, and low-fat dairy. A handful of almonds with an apple, or oatmeal with berries, gives you a slow, sustained release of glucose. If your headache tends to hit in the late afternoon, it’s worth looking at whether you’re going too long between meals or relying on refined carbs at lunch.

Magnesium-Rich Foods

Magnesium plays a direct role in nerve function and blood vessel regulation, and low levels are consistently linked to migraines. The American Migraine Foundation notes that 400 to 600 mg of magnesium daily is used for migraine prevention. While that dose typically requires a supplement, building your diet around magnesium-rich foods creates a solid foundation.

Good sources include pumpkin seeds (one of the most concentrated food sources), dark chocolate, spinach, Swiss chard, black beans, avocados, and cashews. Bananas contain some magnesium but are also high in tyramine, which can trigger headaches in sensitive people, so they’re a mixed bag. If you get frequent migraines, talk to a provider about whether a magnesium supplement makes sense alongside dietary changes.

Fatty Fish and Omega-3s

A study funded by the National Institutes of Health found that people who ate diets higher in omega-3 fatty acids from fatty fish for 16 weeks experienced fewer and less severe headaches. The mechanism is straightforward: your body converts omega-3s into compounds that reduce pain signaling, while omega-6 fatty acids (abundant in processed vegetable oils) get converted into compounds that increase it.

Salmon, mackerel, sardines, herring, and trout are the richest sources. Walnuts, flaxseeds, and chia seeds provide a plant-based form of omega-3, though the conversion to the active pain-reducing compounds is less efficient. Eating fatty fish two to three times per week is a reasonable target. If your current diet is heavy on fried foods, chips, and packaged snacks, simply reducing those omega-6 sources while adding more fish can shift the balance meaningfully.

Riboflavin (Vitamin B2) Sources

Riboflavin has one of the stronger evidence bases among nutrients for migraine prevention. In a randomized trial of 55 adults with migraines, 400 mg per day of riboflavin reduced migraine frequency by two attacks per month compared to placebo. The Canadian Headache Society recommends that same 400 mg dose for prevention, noting that side effects are minimal (mostly discolored urine).

The catch: reaching 400 mg through food alone is nearly impossible. The richest dietary sources are eggs, organ meats like liver, lean meats, milk, and fortified cereals, but even generous portions provide only a fraction of the therapeutic dose. Still, eating riboflavin-rich foods regularly supports your baseline levels, and a supplement can bridge the gap if migraines are frequent.

Ginger for Acute Relief

Ginger has anti-inflammatory and anti-nausea properties that make it useful when a headache is already underway. A small clinical trial found that ginger performed comparably to sumatriptan, a common migraine medication, for acute relief, though the evidence is still limited. Fresh ginger tea is the easiest way to use it: slice a thumb-sized piece of fresh ginger into hot water and steep for 10 minutes. Powdered ginger in warm water works too. The anti-nausea effect is a bonus if your headaches come with stomach upset.

Foods That Commonly Trigger Headaches

Knowing what to eat is only half the picture. Several compounds found in everyday foods are well-documented headache triggers, though the American Headache Society estimates that only about 10% of migraine sufferers are truly sensitive to specific food triggers. The relationship between diet and migraine is, in their words, “vastly misunderstood.” That said, if you notice a pattern, these are the usual suspects worth investigating.

Tyramine builds up in aged, fermented, or overripe foods. Aged cheeses (blue cheese, parmesan, cheddar, old gouda), beef and chicken liver, dried fruits like raisins, and overripe bananas or avocados are the main sources. Tyramine content increases the longer a food sits, so leftovers that have been in the fridge for days contain more than fresh-cooked meals.

Nitrates and nitrites are preservatives found in processed meats: hot dogs, bacon, salami, pepperoni, bologna, beef jerky, sausage, and smoked fish. These compounds affect blood vessel dilation and are among the most consistently reported dietary triggers.

MSG (monosodium glutamate) shows up in restaurant food, flavored snacks, bouillon cubes, seasoned salt, gravies, canned soups, and many processed or ready-to-eat meals. Labels sometimes disguise it as “natural flavoring.”

Histamine accumulates in fermented and aged foods, and people with histamine intolerance frequently report headaches as a primary symptom. Sauerkraut, miso, tempeh, aged cheeses, cured meats, and fermented soy products are all high in histamine. If you notice headaches after eating these foods, it may point to a histamine processing issue worth exploring.

Putting It Together

If you have a headache right now, the most effective immediate steps are drinking water (with electrolytes if you’re dehydrated), eating something with slow-releasing carbs and protein to stabilize blood sugar, and trying ginger tea. A simple meal like scrambled eggs on whole grain toast with a glass of water checks several boxes at once.

For longer-term prevention, the pattern is consistent across the research: eat more fatty fish, leafy greens, nuts, seeds, whole grains, and eggs. Eat less processed meat, aged cheese, and packaged foods with additives. Stay hydrated. Don’t skip meals. These aren’t dramatic changes, but sustained over weeks, they address the most common nutritional contributors to headaches. If migraines are frequent, adding a magnesium or riboflavin supplement on top of dietary changes gives you the best shot at reducing their frequency.