injured my neck sleeping last night. Care barely turn my head this morning. I've done this before hopefully it will clear up again in a day or two. The joys of 50, your worst injuries come not from the 120 miles I put on a bike last week but from sleeping wrong.
Your situation might be different but I went though a phase of something similar.
Thought it was the pillow or just general soreness. Would wake up feeling that dreaded about to cramp feeling that would immediately develop into a spasm + days of stiffness. I thought it was part of getting older.
Turns out in my case, it was back weakness after years of being fit but focussed on anterior everything and cycling.
Pull ups, rows, dumbbell flys, prone Ys, face pulls etc. fixed the issue for good.
Everything posterior chain, but particularly focussing on upper back fixed me permanently. Mind you, good comfortable pull ups took at least 6 months (inc. some injury time).
Now I don't even get a sore neck from sitting at a desk all day anymore. I've also learned that often my "neck pain" was actually referred back pain.
Hope that helps you.