Any of the above, plus dozens of other ordinary events, can give you a headache. What happens in a headache is not a single event, but a cascade of events. The brain itself cannot feel pain. But chemical changes in the brain can affect blood vessels and muscles in and around the head.
Blood vessels swell or shrink, muscles know and head pain in the result.
These changes in the brain occur when amounts of chemicals called neurotransmitters rise or fall. Neurotransmitters carry messages across nerve cells, allowing the brain to think thoughts, direct actions, actions, store memories, recall emotions. Neurotransmitters rise and fall depending on what we eat, how we sleep, what medications we take, whether we are under stress or not and so on. Fluctuations in neurotransmitters can make blood vessels swell or contract in spasms. This irritates surrounding nerve endings, and you feel pain and that is a headache.