There are many different causes of pain in the hip. Since this has been going on for a while, I would definitely recommend that you see your primary care doctor
, who can examine the involved area and help figure out what might be going on.
The fact that the pain occurs mostly when you lay down suggest that it might be bursitis, which is an inflammation of the fluid filled sac that pads the hip joint, or tendonitis in the muscles of the buttocks. The reason that the pain would be worse when you lay down is that you put pressure directly on these inflamed structures by lying down. Your primary care doctor can confirm these diagnoses, which can typically be treated effectively with anti inflammatory medications, although occasionally other interventions are also needed, such as stretching exercises, physical therapy, or even steroid shots into the inflamed area.
Your doctor will also be able to simultaneously rule out the other causes of hip pain, such as hip arthritis
, based on their examination and some additional questions they will ask. They may decided to take x-rays of the hip, but this is not necessary in all cases.
Good luck, and I hope you are feeling better soon!