Headaches that build up right before or during a bout of constipation are a real, recognized pattern, usually linked to straining and gut-related triggers rather than anything more serious. What concerns me more is using 5 painkillers back to back every single episode. Doing that every 2 to 3 weeks can itself turn into a medication-overuse headache that becomes harder to treat over time, on top of the original problem.
Next Steps
Treating the constipation early with regular fibre, fluids and daily movement usually shortens these headache episodes faster than painkillers alone. Please see a general physician to review your painkiller pattern and rule out other headache causes.
Health Tips
Get checked urgently if the headache ever comes on suddenly and severely, or with vision changes, weakness or confusion.