I keep having bad headaches at night what can I do?

Sleep study. A sleep study (nocturnal polysomnography) will be looking for any physical abnormalitie that can triger/worsen headaches.
Headaches. If you have tried all over the counterpain medications, you might consider a magnesium supplement, then see your doctor. You might need a daily medication like topamax (topiramate) or Propranolol to keep the headaches away. You can also find out if your headaches are coming from tension, eye strain, dehydration, lack of sleep/poor sleep, skipping meals, stress, sleep apnea/snoring, or chronic sinus problems.