I have had sleeping problems for tbe past 3 months. Throughout the night I get 2 hours sleep max. I wake up with a really bad headache. Why?

It maybe . Cluster headaches have also been called alarm clock headaches because they often wake the patient up during the night or in the early morning, according to the national headache foundation. I would also get general check up, blood pressure check, use nasal rinse if I have stuffy nose/sinus congestion.
Insomnia. It appears you have insomnia. There is primary insomnia - lack of sleep due to no other identifiable reason and secondary - when insomnia is caused by another problem such as pain, depression or anxiety. Lack of sleep has been associated with headaches in the morning due to lack of rest for your brain. Discuss that with your doc and work out a plan to combat it.