Several foods can help relieve or prevent headaches by addressing common underlying causes like dehydration, inflammation, and nutrient deficiencies. The most effective options are rich in magnesium, omega-3 fatty acids, water, or B vitamins. But some foods that seem healthy can actually trigger headaches in sensitive people, so knowing which to reach for and which to avoid matters just as much.
Water-Rich Foods for Dehydration Headaches
Dehydration is one of the most common and easily fixable headache triggers. Even mild fluid loss can cause the brain to temporarily contract from the skull, producing that dull, pressing pain across the forehead or temples. If your headache started after skipping water, sweating, or drinking alcohol, rehydrating is the fastest path to relief.
Plain water works, but water-rich foods help too because they deliver fluid alongside electrolytes that improve absorption. Watermelon, cucumber, and celery are particularly high in water content. Eating them alongside drinking water can speed up rehydration compared to water alone. Swapping sugary drinks for these options also avoids the blood sugar spike and crash that can make headaches worse.
Magnesium-Rich Foods
Magnesium plays a central role in nerve signaling and blood vessel function, and low levels are strongly linked to headaches, especially migraines. Supplemental magnesium at 400 to 600 mg per day is a well-established preventive strategy recommended by the American Migraine Foundation. But you can also boost your intake through food.
The best dietary sources of magnesium include pumpkin seeds (one ounce delivers roughly 40% of the daily value), spinach, Swiss chard, black beans, quinoa, and dark chocolate (70% cacao or higher). Almonds and cashews are also excellent sources, though some people with migraines find nuts to be a trigger, so pay attention to your own patterns. If you get frequent headaches and suspect your magnesium is low, increasing these foods consistently over weeks is more useful than eating a handful of spinach during an active headache.
Fatty Fish and Omega-3s
Omega-3 fatty acids reduce neuroinflammation, which is one of the key processes driving migraine attacks. These fats work by producing specialized compounds that actively resolve inflammation rather than just blocking it. They also have pain-reducing and antioxidant properties in the nervous system.
Salmon, mackerel, sardines, and anchovies are the richest sources of the two omega-3s that matter most here (EPA and DHA). Eating fatty fish two to three times a week builds up tissue levels over time, which is where the headache prevention benefit comes from. A single serving during a headache won’t provide immediate relief, but a consistent dietary pattern can reduce how often headaches occur and how severe they are. Plant sources like flaxseed, chia seeds, and walnuts contain a precursor form of omega-3 that your body converts less efficiently, so fish remains the stronger option.
Ginger for Active Headache Relief
Ginger stands out because it can help during a headache, not just as a long-term preventive strategy. In a clinical trial published in Phytotherapy Research, ginger powder matched the prescription migraine drug sumatriptan in pain reduction. Both treatments reduced pain scores by nearly identical amounts (4.6 and 4.7 points on a 10-point scale) within two hours.
Fresh ginger tea is the simplest way to use this. Slice about an inch of fresh ginger root, steep it in hot water for 10 minutes, and drink it at the first sign of a headache. Powdered ginger in capsule form also works. Ginger has fewer side effects than most medications, though it can cause mild stomach warmth in some people.
Riboflavin (Vitamin B2) Sources
Riboflavin helps your cells produce energy more efficiently, which matters because the brains of people who get migraines appear to process energy differently. A randomized controlled trial published in Neurology tested 400 mg of riboflavin daily and found it significantly reduced migraine frequency over three months.
Getting 400 mg purely from food is difficult since even the richest sources contain only a few milligrams per serving. But regularly eating riboflavin-rich foods can still contribute meaningfully. Beef liver is by far the most concentrated source, followed by fortified cereals, eggs, lean beef, mushrooms, and dairy milk. If you get frequent migraines, combining these foods with a B2 supplement is a reasonable approach.
Foods That Support Brain Energy
Your brain consumes a disproportionate amount of your body’s energy, and disruptions to that energy supply can trigger headaches. Coenzyme Q10, a compound involved in mitochondrial energy production, has shown promise for migraine prevention. Your body makes some CoQ10 naturally, but levels decline with age.
Organ meats, beef, chicken, trout, and sardines are the richest food sources. Broccoli, cauliflower, and soybeans contain smaller amounts. Like riboflavin, the quantities in food are modest compared to supplement doses used in studies, but a diet consistently rich in these foods supports the same energy pathways.
Foods That Can Make Headaches Worse
Some foods that are otherwise nutritious contain tyramine, a compound produced when the amino acid tyrosine breaks down over time. Tyramine affects blood vessels and can trigger headaches in sensitive individuals. The longer a food is aged, fermented, or stored, the more tyramine it accumulates.
The biggest offenders include aged cheeses (blue cheese, brie, cheddar, Swiss, provolone), fermented foods like sauerkraut and kimchi, soy sauce, miso, and cured meats such as pepperoni, salami, and jerky. Even some fruits need moderation: avocados, bananas, figs, raisins, and dried fruit contain enough tyramine or related compounds to be problematic for some people. The National Headache Foundation recommends limiting these to half a cup per day if you’re sensitive.
A few other common triggers to watch for:
- Alcohol, particularly red wine, beer, and sherry, which combine tyramine with other headache-promoting compounds
- MSG in large amounts, along with nitrates and nitrites found in processed meats like hot dogs, bacon, and deli meat
- Pickled foods including olives, pickles, and pickled herring
Freshness is a practical rule of thumb. The National Headache Foundation advises eating high-protein foods fresh and freezing leftovers within two to three days rather than letting them sit in the refrigerator, where tyramine levels gradually climb.
Putting It Together
If you’re dealing with an active headache right now, your best immediate options are drinking water, eating water-rich fruits like watermelon, and brewing fresh ginger tea. These address the most common acute triggers and can provide relief within an hour or two.
For reducing headache frequency over time, the strongest dietary strategies are building in magnesium-rich foods daily (leafy greens, seeds, beans), eating fatty fish several times a week, and avoiding your personal trigger foods. Keeping a simple food diary for a few weeks can reveal patterns you might not notice otherwise, since tyramine sensitivity and other triggers vary widely from person to person.