Overview
Neck pain and headaches are often mentioned at the same time, as a stiff neck can cause a headache.

Stiff neck

Your neck is defined by seven vertebrae called the cervical spine (the top part of your spine). It’s a complex combination of working parts — muscles, ligaments, vertebrae, blood vessels, etc. — that support your head.

If there’s damage to the nerves, vertebrae, or other neck components, it can cause your muscles to tense. This can lead to pain.

Headache

When your neck muscles tense up, the result can be a headache.

Tension headaches
The source of a tension headache is often traced back to a buildup of:

stress
anxiety
lack of sleep
These conditions can result in tightened muscles at the back of your neck and base of your skull.

A tension headache is often described as mild to moderate pain that feels like a band tightening around your head. It’s the most common type of headache.

Treating a tension headache

Your doctor might recommend any of a variety of medications, including:

Over-the-counter (OTC) pain relievers. These include ibuprofen (Motrin, Advil) or acetaminophen (Tylenol).
Prescription pain relievers. Examples include naproxen (Naprosyn), ketorolac tromethamine (Toradol), or indomethacin (Indocin)
Triptans. These drugs treat migraines and would be prescribed for someone experiencing tension headaches along with migraines. An example is sumatriptan (Imitrex).
For migraine, your doctor might also recommend preventive medication, such as:

tricyclic antidepressants
anticonvulsants
blood pressure medications
Your doctor might also recommend massage to help relieve the tension in your neck and shoulders.

Pinched nerve causing stiff neck and headache
A pinched nerve occurs when a nerve in your neck is irritated or compressed. With so many sensory nerve fibers in the spinal cord in your neck, a pinched nerve here can result in a number of symptoms, including:

stiff neck
throbbing headache in the back of your head
headache caused by moving your neck
Other symptoms can include shoulder pain along with muscle weakness and numbness or tingling sensations.

Treating a pinched nerve in your neck

Your doctor may recommend one or a combination of the following treatments:

Cervical collar. This is a soft, padded ring that limits motion. It allows the neck muscles to relax.
Physical therapy. Following a specific set of guided, physical therapy exercises can strengthen neck muscles, improve range of motion, and relieve pain.
Oral medication. Prescription and OTC medications your doctor might recommend to ease pain and reduce inflammation include aspirin, naproxen, ibuprofen, and corticosteroids.
Injections. Steroid injections are used to lessen swelling and relieve pain for a long enough period for the nerve to recover.
Surgery is an option if these less invasive treatments don’t work.

Herniated cervical disc causing stiff neck and headache
A herniated cervical disc occurs when one of the soft discs between one of the seven vertebrae in your neck becomes damaged and bulges out of your spinal column. If this presses on a nerve, you can feel pain in your neck and head.

Treating a herniated cervical disc

Surgery for a herniated disc is necessary for only a small number of people. Your doctor will recommend more conservative treatments instead, such as:

OTC pain medications, such as naproxen or ibuprofen
prescription pain medications, such as narcotics like oxycodone-acetaminophen
muscle relaxers
cortisone injections
certain anticonvulsants, such as gabapentin
physical therapy
Preventing stiff necks and headaches
To prevent headaches related to neck pain, there are things you can do to avoid a stiff neck at home. Consider the following:

Practice good posture. When standing or sitting, your shoulders should be in a straight line over your hips with your ears directly over your shoulders. Here are 12 exercises to improve your posture.
Adjust your sleep position. Try to sleep with your head and neck aligned with your body. Some chiropractors recommend sleeping on your back with a pillow under your thighs to flatten your spinal muscles.
Customize your workspace. Adjust your chair so your knees are a bit lower than your hips. Place your computer monitor at eye level.
Take breaks. Whether you’re working at your computer for long periods of time or driving long distances, frequently stand up and move. Stretch your shoulders and neck.
Quit smoking. Among other problems it can cause, smoking can increase your risk of developing neck pain, reports the Mayo Clinic.
Watch how you carry your stuff. Don’t use an over-the-shoulder strap to carry heavy bags. This goes for purses, briefcases, and computer bags, too.