Hi, I get this problem as well. I have figured out that for me at least it is salt related. I'm not a doctor but I know some basic biology about cells. If you are very dehydrated, the amount of water in your blood is low, so the dilution of salt and other electrolytes is relatively high. This makes your cells lose water and shrink (water moves across membranes to try to equalize the dilution of salt inside and outside the cells). When you drink water, you quickly lower the dilution of salt in your blood. This makes your cells gain water and swell. Your brain literally swells and puts pressure inside your skull. If I am very dehydrated (which I often am), I add a pinch or two of sea salt to each glass of water I drink at first and this seems to prevent the headaches. Another important electrolyte in the blood is potassium so eating a banana or potato may help, or there are salt substitutes made of a potassium compound. To test out if you have this problem, drink a sports drink like Gatorade, or an oral rehydration solution like Pedialyte. If you can tolerate those without getting a headache, then your problem is likely from quickly desalinating yourself and you just need to add electrolytes to your body when rehydrating. Hope this helps!