context: There is no perfect treatment for pain and sleeplessness. It all depends on your particular case -- the kind of pain you have and the other medications you take, for instance. The first step for anyone with sleep problems is to improve their sleep habits. This helps set the stage for a good night's rest. You might also benefit from medication. Some drugs ease pain, which can help with sleep. Other medicines are available to just aid sleep problems. Many people need both. But don't treat chronic pain and insomnia on your own. Over-the-counter drugs are not intended for long-term use. Instead, talk to your health care provider so you can get a personalized treatment plan. Here are some of the drugs that help people with chronic pain feel better and get some rest. Drug Class Benefits Risks Over-the-counter NSAIDs (nonsteroidal anti-inflammatory drugs) Aspirin ( Bayer, Excedrin) Ibuprofen ( Advil, Motrin) Ketoprofen Naproxen ( Aleve) Relieves pain and reduces swelling Side effects include a risk of ulcers and bleeding. Not for long-term use unless recommended by your health care provider. Take with food. Over-the-counter acetaminophen Tylenol Panadol An ingredient in Excedrin Relieves pain They can also cause liver toxicity in high doses. Not for long-term use unless recommended by your health care provider. Over-the-counter combined sleep aids/pain drugs ibuprofen and diphenhydramine ( Advil PM) acetaminophen and diphenhydramine ( Tylenol PM) Relieves pain and helps with sleep These drugs help you sleep by including an antihistamine, an ingredient in cold medicines that may also work as a sedative. However, according to the National Institutes of Health, the effectiveness of antihistamines as a sleep aid is not well established and they can have side effects like daytime drowsiness and decreased cognitive function. Not for long-term use. Opioid painkillers codeine morphine oxycodone ( Oxy Contin) oxycodone with acetaminophen ( Percocet, Roxicet) hydrocodone with acetaminophen ( Vicodin) lorcet ( Lortab) Relieves more severe pain Side effects include nausea, constipation, and a risk of addiction. Some of these medicines can disrupt the natural sleep cycle, reducing the amount of deep sleep you get. Muscle relaxants cyclobenzaprine baclofen metaloxalone ( Skelaxin) carisoprodol ( Soma) Relieves more severe pain Relieves pain from spasm and helps with sleep. Side effects include drowsiness, dry mouth, constipation and confusion. Should not be used for long-term pain relief. Benzodiazepines lorazepam ( Ativan) flurazepam triazolom ( Halcion) clonazepam ( Klonopin) temazepam ( Restoril) diazepam ( Valium) Used to reduce anxiety, benzodiazepines can also aid with sleep. These drugs are not for long-term use. Side effects can include daytime sleepiness, cognitive impairment, and dependence/addiction. They can also reduce the amount of REM sleep. Nonbenzodiazepine hypnotics zolpidem ( Ambien, Edluar, Intermezzo) eszopiclone ( Lunesta) zaleplon ( Sonata) Aids with sleep, while not causing the same disruptions to the sleep cycle that benzodiazepines do; they are generally considered to be safer for longer use. Side effects can be similar to those of benzodiazepines, although generally less severe. Anticonvulsants tiagabine ( Gabitril) carbamazepine ( Carbatrol, Tegretol) gabapentin ( Neurontin, Horizant) topiramate ( Topamax, Qudexy XR, Trokendi XR)) Originally used to prevent seizures, these drugs can also help with nerve pain. Side effects include drowsiness and dizziness. You should never stop taking these medicines abruptly. Antidepressants nortriptyline ( Aventyl, Pamelor) trazodone amitriptyline nefazodone duloxetine ( Cymbalta) Reduces pain, particularly for headache, nerve pain, and fibromyalgia; some can aid sleep. Cymbalta is approved for musculoskeletal pain. These drugs may not be effective for other types of pain, like sports injuries or back pain. Antidepressants are powerful drugs that can have serious side effects. Talk to your health care provider about side effects you should watch out for.