The pain is due to irritation or injury of nerves, pinching of nerves by tight neck muscles, compression of nerves as it leaves the
spine secondary to
osteoarthritis or tumors in the neck. Local inflammation or infection, gout, diabetes etc. you need to consult a neurologist who will do a detailed neurological examination, X-ray upper spine, eliciting tenderness over affected nerve, relief from pain after an anesthetic block will be needed to confirm diagnosis.