Pain and stiffness in the neck upon awakening is rarely a sign of a significant or serious medical problem. Rather, it tends to be the result of poor posture while sleeping. There are several simple maneuvers that you can do while sleeping to improve your posture and prevent this problem.
In general, you should try to sleep in a position such that your head is in a direct like with your body and spine. You should avoid curling up or extending the neck while sleeping. Sleeping on your stomach is particularly bad as it places the most strain on the neck. Probably the best position is to sleep on your side with your knees slightly bent. You should also avoid sleeping with too many pillows, as this flexes the neck and takes it out of alignment. 1 or 2 firm pillows that adequately support your neck should be enough.
To relieve the pain, consider taking an over the counter anti inflammatory medicine like ibuprofen or naprosyn. However, if the pain is persistent or worsens, or if you notice any numbness
or tingling in your hands or arms, you should see your primary care doctor
immediately, as these may be signs of a worsening condition.