So you’ve just discovered that boxed wine and cheap whiskey don’t necessarily mix well, and you’ve got the vicious headache to prove it. Headaches aren’t always party-aftermath related, but they are always a bummer, and they’re also unfortunately very common. It’s estimated that about half of adults worldwide have had a headache in the last year, and 30 percent of those believed they had suffered a migraine.

Not only is it annoying AF, but it can also be potentially dangerous. One study suggests that headache disorders (including migraines) are the third highest cause of disability worldwide due to their significant impact on quality of life and the financial cost of being unable to work. While sometimes the cause is environmental or physiological, research shows that diet may play a notable role. Here are the top foods to avoid (or load up on) to ease the pain.

Worst Foods for Headaches

Alcohol

I know. I know. Thanks, Captain Obvious. But it’s too common not to put on the list. Headaches from alcohol tend to creep up either immediately (as soon as 30 minutes to 3 hours after a drink for migraine sufferers) or in the form of the dreaded hangover the next day. In fact, people who get migraines may experience a headache after only a single small drink.

Interestingly, research suggests that migraine sufferers tend to drink less alcohol than their headache-free counterparts, likely because of the risk of an attack. What remains less clear is if it’s the alcohol or some other component of a drink that triggers it. Tyramine, phenylethylamine, histamine, sulfites, and flavonoid phenols are commonly found in our favorite drinks and have all been suspected as a potential cause of migraines. In fact, it’s not uncommon for studies to suggest an increase in migraine episodes following a glass of sulfite- and histamine-filled red wine.

Want to cut back on the chance of an attack? For one, drink moderately (that’d be one drink per day for women and two for men). No weekend benders for you! And two, choose a light colored drink like gin or vodka over red wine or dark liquors, which tend to have lower amounts of headache-inducing histamine and sulfites.

Excessive (and Then the Absence of) Coffee

Ah yes, take away the morning Joe and get ready for a real pounder. One Norwegian study found that individuals with the highest intake of caffeine (more than 540 mg per day) were 10 percent more likely to get headaches and migraines. Other population-based studies have concurred, citing a greater prevalence of headaches with excessive levels of consumption.

To avoid the nasty effect, experts recommend limiting your intake to no more than 400-500 mg/ day (about 4 cups of coffee, which is still pretty generous!), and more importantly, being consistent in your intake. In other words, don’t go on a coffee binge on Saturday morning, only to go cold turkey in the days to follow. Our tip for cutting back? Go half-caf until you can slowly wean yourself off the liquid energy.

Chocolate

Ugh, I know. You didn’t want to see this one on the list. But at least it’s still debatable. One study compared chocolate with a placebo and found that the chocolate triggered a migraine in 42 percent of subjects. Having said that, another study compared chocolate with carob and found no difference in headache complaints. The likely culprit? It looks as if the phenylethylamine and tyramine amino acids found in chocolate may be responsible.Research has found greater amounts of phenylethylamine and tyramine in people who suffer from chronic migraines. It seems possible that chocolate might be a trigger for some, but not others, so definitely try to pay attention to the outcome after your next treat.

Artificial Sweeteners

It might not be just the caffeine in your Diet Coke that’s giving you a headache. Research suggests that artificial sweeteners, particularly the super-popular aspartame, may increase the risk of migraine headaches and reduce the percentage of days subjects were headache-free. Apparently calorie-free doesn’t necessarily mean pain-free, so try cutting back on the bubbly stuff.

Citrus Fruit

A healthy food on the no-no list? Sadly, our favorite source of vitamin C may be a trigger for some. One study found that 11 percent of migraine sufferers self-reported an uptick in symptoms after eating citrus fruit. Another study, however, was not able to see a significant difference in headaches between those who did and did not consume citrus. If citrus is a problem for headache sufferers, the likely culprit is higher amounts of the amino acid tyramine found in the fruit. Other high-tyramine foods include pineapple, soy, kimchee, raw onions, fava beans, and sauerkraut.

Aged Cheese

Feeling the pressure after a fancy cheese plate? You may not be alone. The process of fermentation, which is key in the production of cheeses like blue, cheddar, Parmesan, and Camembert, increases the levels of tyramine and phenylethylamine amino acids in food. Not surprisingly, one study found that 18 percent of migraine sufferers complained that aged cheese was the root cause of their pain. Need to get your fix? Try ricotta, cream cheese, farmer cheese, cottage cheese, or American instead for a lower tyramine option.

Processed Meat

We hear the word “nitrates” all the time in the context of chronic disease, but it seems they might not be so kind to our noggin, either. Research suggests that the common food preservatives found in processed foods like hot dogs, sausage, and cold cuts may be linked to migraines in some populations. It seems that the presence of nitrate, nitrite, and nitric oxide reductase genes related to the composition of gut bacteria is responsible for determining who suffers and who doesn’t. Apparently we’ve got another reason to limit the street meat.

Best Foods for Headaches

Water

So it’s not technically a food, but there’s a reason water tastes so good when you’re not feeling your best. Dehydration is one of the leading causes of headaches in general, so it makes sense that getting your eight glasses a day may help. In one study looking at water intake and headache incidence, water was significantly associated with a reduction in headache intensity and duration.

Another study found that 47 percent of headaches were improved simply by drinking up, compared with 25 percent of sufferers in a control group who did not. We suggest carrying a full bottle of water around and listening to your body for those early signs of thirst before it gets to an extreme.

You can also help meet your hydration needs by fitting plenty of fruits and veggies with a high water content into your diet. Cucumbers, spinach, watermelon, and berries can all help quench your thirst and supply a range of important vitamins and minerals to keep headaches at bay, says Josh Axe, DNM, DC, CNS, and author of Eat Dirt.

Low-Sodium Foods

While research on salt and headache incidence is in its infancy, one study analyzing the effect of a low-sodium diet found that the likelihood of having a headache was lower when consuming less salt. One easy way to cut back? Avoid those processed foods and meats, which are also rich in those potentially problematic nitrates.

Leafy Greens

Yep, another win for kale. Leafy greens, like kale, spinach, and chard, are loaded with the B vitamin folate, which may play a unique role in the risk of headaches. Early research on women suggests that a diet low in folate may increase the frequency of migraines compared to women with adequate levels in their diet. Not a salad fan? Try avocado, seeds, and legumes to get your folate fix (but also… just try to eat your greens).

In addition to being high in folate, leafy greens are an excellent source of magnesium. Some studies suggest that a low level of this essential mineral may be to blame for headache symptoms, making it even more important to get in your daily dose of greens, Axe says.

Almonds

Research suggests that migraine sufferers tend to have lower levels of serum magnesium, and almonds are one of the greatest (and tastiest) sources to meet your needs. While research specifically looking at the impact of magnesium-rich foods (like almonds) on headaches is scarce, studies suggest that supplementing with 600 mg of magnesium each day reduces the frequency of migraines. While you may need a supplement, we suggest trying a food-first approach, and if you’re not into almonds, try leafy greens, seafood, pulses, and other nuts and seeds.

Milk

Like magnesium, the other two major bone-building nutrients, calcium and vitamin D, seem to play a role in headache prevention. One study found that a combination of calcium and vitamin D supplements significantly reduced migraine attacks, while patients in another study saw significant improvements in just 4 to 6 weeks. Vitamin D does seem to play a bigger role than calcium, but you can get your fix of both from fortified products like dairy, soy milk, eggs, and orange juice.

Small Amounts of Coffee

What the what?! Coffee on the naughty and nice list!? Yep. It’s all about the dose. Consistently overdo it with the caffeine and then pull right back? You’re asking for a real doozy. But research suggests that very small amounts of caffeine may actually be beneficial. A systematic review of the literature found that consuming about 100 mg of caffeine a day (the amount in a small cup of coffee) along with pain medication may provide more headache relief than meds alone.

Hey, we can’t change the weather, control the pollution, or turn off some genetic predisposition, but we can control what we put in our mouths. If you’re suffering from consistent headaches or migraines, we recommend making a journal and tracking what you eat before a migraine attack to determine which of these foods are hurting (or helping) your pain.

Preventing headaches can also extend beyond what you’re putting on your plate. In addition to switching up your diet, remember to get plenty of regular physical activity, set a consistent sleep schedule, and minimize your stress levels, Axe says.