I have had this problem a few times, and found it was due to my stress.
After thinking about it, I decided if the stress was cycling related, or external to cycling.
When I decided the stress was external to cycling, I made an effort to focus completely on the ride, and on longer rides. I was ignoring the destination and any cares that may be there.
At one point I decided that the numbers on my bike computer were causing stress. I was struggling to maintain the average speed I'd targeted, or my cadence had dropped below X, or ... you get the idea. I solved this by taking the bike computer off the bike, just riding by feel.
In another case, I had been increasing my training load, which is also a stress. My shoulders are hunched right now, thinking about it. My solution was to back off the training a little, and enjoy it more.
Hope that helps.