Researchers don’t know exactly what causes some people to get migraines. Genes, changes in the brain, or changes in levels of brain chemicals could be involved.

But it’s clear that certain things set off migraine attacks. Specific foods, hormonal changes, and stress are among the most often-cited migraine triggers. Weather can also be a factor.

According to a 2015 analysis done in Taiwan, up to half of people living with migraine say changes in the weather cause their headaches. Storms, temperature extremes, and changes in barometric pressure might all contribute to these headaches by altering levels of serotonin and other brain chemicals.

The research on the connection between migraine and weather changes has been mixed, in part because it has been difficult to study. People have varying reactions to weather changes, so it’s hard for researchers to narrow down one cause.

Not everyone responds to weather changes in the same way. Heat triggers headaches in some people, while others get a migraine when the temperature drops. Certain people are more sensitive than others to shifts in temperature and humidity.

In some cases, many different factors come together to trigger a migraine attack. For example, you might get headaches on humid days, but only if you’re also stressed or hungry.

There may be a link between temperature, humidity, and migraine, but it’s not always consistent. In general, higher temperatures and humidity seem to set off migraine headaches. Sudden changes in temperature or humidity — up or down — might be also be a factor.

A 2017 study in the International Journal of Biometeorology found an increase in emergency department visits for migraines on warm and humid days, and a drop on cold, dry days. Another study showed an increase in emergency room admissions on hot, dry days.

One possible reason for the increase in headaches during hot weather could be dehydration, which is a recognized migraine trigger.

How you respond to temperature and humidity could depend on how sensitive you are to these factors. In one study, people who were temperature sensitive got more headaches in the winter, while those who weren’t temperature sensitive had more headaches in summer.

Sometimes sunlight can cause a migraine attack. This makes sense, considering that bright light is a common trigger.

Researchers say sunlight could travel through the retina and optic nerve and activate sensitive nerve cells in the brain. Another theory is that ultraviolet radiation from the sun leads to the release of chemicals in the skin that widens blood vessels, which can cause a migraine.

The strength and brightness of sunlight could help determine whether it causes a migraine attack. In one small study, people got more migraines when exposed to summer sun (which is stronger) than winter sun (which is weaker).

Barometric pressure is a measurement of pressure in the air. Rising barometric pressure means the air pressure is increasing. Falling barometric pressure means air pressure is decreasing.

How does barometric pressure influence headaches? The answer has to do with blood vessels: When the pressure rises, blood vessels narrow; when the pressure drops, blood vessels widen.

A small study from Japan found an increase in migraine attacks when the barometric pressure dropped even slightly. The authors say a drop in barometric pressure causes blood vessels in the brain to widen, which triggers the release of serotonin.

As serotonin levels rise, they set off the visual phenomenon known as aura. When serotonin levels drop again, the blood vessels swell and trigger a migraine.

Although you can’t control the weather, you can gain more control over your migraines when the temperature or humidity changes. One way is to figure out your triggers. Keep a diary of what you’re doing when your migraines start. Over time, you’ll be able to see which weather patterns tend to set off your headaches.

If you’re on a preventive medication, make sure you take it. And have an abortive medication ready if the weather looks like it’s changing.

Try to limit your time outdoors when conditions look like they could set off a headache. And if you do have to be out in the sun, shield your eyes with a pair of UV-protective sunglasses.