The neck carries the weight of the head all day and is supposed to rest at night. When the head is held tilted, twisted or pushed forward for hours, the small muscles along the side of the neck stay stretched on one side and shortened on the other. In the morning they protest.
The pillow question
A pillow that is too high bends the neck sideways for back and side sleepers alike; one that is too flat lets the head drop. The aim is simple: when you lie on your side, your nose should line up roughly with the middle of your chest. Many people sleep on the same pillow for years after it has lost its shape.
Stomach sleeping
Lying face down forces the head to turn fully to one side for most of the night. It is the position most often linked with waking up stiff. Moving gradually to the side, with a pillow in front to hug, is easier than trying to switch to the back overnight.
Easing it during the day
Gentle movement usually helps more than keeping the neck completely still. Slow turns within a comfortable range, a warm shower aimed at the sore side, and frequent breaks from looking down at a phone let the muscles settle within a day or two.
When it is more than a bad night
Stiffness with fever and headache, pain spreading down an arm with tingling or weakness, or stiffness that follows a fall or a car accident should be examined promptly. Ordinary morning stiffness improves steadily; anything that keeps getting worse is worth a visit.