What to Eat When You Have a Headache and What to Avoid

Certain foods can help relieve a headache you already have, and eating the right things regularly can make headaches less frequent over time. The best immediate choices are hydrating foods, ginger, a small amount of caffeine, and meals that stabilize your blood sugar. For longer-term prevention, foods rich in magnesium, omega-3 fatty acids, and riboflavin (vitamin B2) all have evidence behind them.

Hydrating Foods for Quick Relief

Dehydration is one of the most common and overlooked headache triggers. If you haven’t been drinking enough water, eating high-water-content foods can help you rehydrate faster than water alone, because fruits and vegetables also deliver electrolytes like potassium, calcium, and magnesium that support fluid balance in your body.

Some of the best options, ranked by water content: cucumbers (96%), celery (95%), lettuce (94 to 96%), tomatoes (94%), bell peppers (92 to 94%), watermelon (92%), strawberries (91%), cantaloupe (90%), and oranges (87%). Soups, stews, and gazpacho also count toward hydration and can be easier to eat when you’re not feeling well. Pair these with a glass of water for the fastest effect.

Ginger for Active Headache Pain

Ginger is one of the few foods with clinical evidence for treating a headache that’s already started. In a study comparing ginger powder to sumatriptan (a common migraine medication), participants who took 250 mg of ginger at headache onset experienced nearly identical pain reduction at the two-hour mark. That 250 mg is roughly a quarter teaspoon of ground ginger.

You can stir ginger powder into hot water for a quick tea, grate fresh ginger into broth, or chew on a small piece of crystallized ginger. The key is taking it early, right when you feel the headache coming on, rather than waiting until the pain peaks.

Caffeine: Helpful in Small Amounts

A small dose of caffeine narrows dilated blood vessels and can boost the effectiveness of pain relievers you may already be taking. Research suggests around 100 to 130 mg provides a meaningful benefit. That’s roughly one standard cup of drip coffee or two cups of black tea.

The catch is that regular high caffeine consumption can itself contribute to chronic headaches, and skipping your usual dose causes withdrawal headaches. If you don’t normally drink caffeine, a single cup of coffee or tea during a headache can genuinely help. If you already drink several cups a day, adding more is unlikely to do much good and may make things worse over time.

Stabilize Your Blood Sugar

Skipping meals or going too long without eating causes blood sugar to drop, which commonly triggers headaches. If your headache hit after a long gap between meals, eating something is the most direct fix.

The best approach is pairing a complex carbohydrate with a protein source. Complex carbs (whole grains, sweet potatoes, oats, lentils) raise blood sugar gradually rather than spiking it, and protein slows digestion further. Good combinations include oatmeal with nuts, whole grain toast with peanut butter, or a sweet potato with eggs. Avoid sugary snacks, which spike blood sugar fast and then crash it again, potentially restarting the cycle.

Magnesium-Rich Foods

Magnesium plays several roles in headache prevention. It helps prevent narrowing of blood vessels in the brain caused by serotonin, may block pain-transmitting chemicals like glutamate, and can inhibit the wave of abnormal brain signaling that causes migraine aura. Many people with frequent headaches have low magnesium levels.

Good dietary sources include pumpkin seeds, almonds, cashews, spinach, black beans, edamame, dark chocolate, and avocado. (Note that avocado is also listed as a potential trigger for some people, so pay attention to your own response.) Incorporating a handful of nuts or a serving of leafy greens daily is a simple way to boost your intake. While magnesium works better as a preventive strategy than an acute fix, consistently eating these foods may reduce how often headaches occur.

Omega-3 Fatty Acids From Seafood

A landmark study funded by the National Institutes of Health found that participants who ate a diet higher in omega-3 fatty acids (found in seafood) and lower in omega-6 fatty acids (found in vegetable oils like corn, soybean, and sunflower oil) had fewer headache days per month, fewer hours of headache overall, and less moderate-to-severe pain compared to those eating a typical diet.

The most effective sources are fatty fish: salmon, mackerel, sardines, herring, and anchovies. Eating two to three servings per week increases your omega-3 levels meaningfully. At the same time, reducing your intake of fried foods, processed snacks, and dishes cooked in vegetable oils lowers omega-6 levels, which appears to amplify the benefit.

Riboflavin (Vitamin B2) for Prevention

Riboflavin at high doses has been shown to reduce migraine frequency by about two attacks per month. The Canadian Headache Society recommends 400 mg per day for migraine prevention, though they note the evidence is still limited. Side effects are minimal, mostly just discolored urine.

Reaching 400 mg through food alone is essentially impossible. Beef liver, the richest dietary source, contains about 2.9 mg per serving. Yogurt, milk, eggs, fortified cereals, and lean meats all contribute smaller amounts. Eating these foods regularly supports your baseline riboflavin levels, but if you’re interested in the migraine-prevention dose, a supplement is the practical route.

Foods That Commonly Trigger Headaches

What you avoid can matter as much as what you eat. That said, the American Headache Society estimates only about 10% of people with migraines are truly sensitive to specific food triggers. The best approach is paying attention to patterns in your own diet rather than eliminating everything on a list.

The most frequently reported trigger foods and ingredients include:

  • Aged cheeses: brie, cheddar, parmesan, gouda, swiss, blue cheese, and similar varieties. These are high in tyramine, a compound that accumulates as cheese ages.
  • Processed and cured meats: hot dogs, pepperoni, salami, jerky, sausages, and deli meats. These contain nitrates and nitrites as preservatives.
  • MSG and related additives: found in soy sauce, bouillon cubes, seasoned salts, and many packaged foods labeled “natural flavoring” or “hydrolyzed protein.”
  • Alcohol: red wine, beer, and sherry are the most common offenders.
  • Chocolate and nuts: especially peanuts, though this varies widely between individuals.
  • Artificial sweeteners: particularly aspartame.
  • Fresh yeast products: fresh-baked bread, bagels, doughnuts, and sourdough. Interestingly, freezing bread may deactivate the yeast and reduce this effect.

A Simple Headache Meal Plan

If you have a headache right now, start with a large glass of water, a cup of ginger tea, and a balanced snack like oatmeal with walnuts or whole grain crackers with cheese (not aged). If caffeine isn’t part of your daily routine, a single cup of coffee can help.

For ongoing prevention, the pattern that emerges from the research is straightforward: eat regular meals so your blood sugar stays stable, include fatty fish two to three times a week, choose magnesium-rich snacks like nuts and seeds, stay well hydrated with water and high-water-content produce, and keep a mental note of which specific foods, if any, seem to precede your headaches. Small, consistent dietary shifts tend to be more effective than dramatic elimination diets.