Melatonin: On most days I take a 3mg capsule of melatonin near bedtime. It is a natural human hormone that has many roles, but it is as an aid to sleep that I take it. There are many possible causes for a person not secreting enough melatonin. One of the causes is prescribed medication: e.g. beta-blockers such as propranolol can deplete our bodies of melatonin. So if your sleep has deteriorated and you are puzzled as to what has caused this, it may possibly be a side-effect of tablets you are taking or have taken.
But it may be that, like me, you are in a lot of pain and that pain is keeping you awake. - You may feel pretty desperate at times because of severe lack of sleep. You may be wondering whether sleeping pills would be helpful. - I hope you will decide against that course of action. - If you look on the internet you will find a wealth of research findings about the adverse effects of sleeping tablets, or hypnotics as they are also known. And these side-effects are even more harmful to older people. Sleeping tablets are harmful and dangerous and should be avoided, especially by older people.
Doctors often confuse pain, insomnia and depression, so they sometimes persuade patients, particularly female patients, to take antidepressants when they are in pain. Antidepressants do not work for depression and seldom help with pain. They are sometimes helpful for insomnia, but most of them cause serious weight gain and many other adverse side-effects and also cause brain damage years later, so they are better avoided.
The other medication you may be considering, or have very likely tried, is analgesia/painkillers. And you may, like me, have found that they do not help at all with the pain or with the sleep problem. Or you may, like me, be concerned about the many harmful side-effects from them. And you may, like me, prefer 'natural' help when possible, rather than pharmaceutical products.
Well the natural ways to reduce chronic pain are to avoid salt and salty food, and avoid dieting and calorie-counting. And obesity is linked to poor sleep and to greater sensitivity to pain, so it is helpful to lose excess weight. Eat good, nutritious food, preferably low carb, low sugar and high fat of the good sort, such as from grass-fed cows. See LCHF. Make sure you get enough calcium and vitamin D. - See this Fat Retention page, with further information about calcium and vitamin D.
And one of the ways to help with poor sleep is to take melatonin. I believe it is safer than hypnotics, antidepressants and painkillers. - I'm assuming you have already made sure the bed is as comfortable as possible and that the curtains keep out unnecessary light, etc.