It helps to have habits that promote healthy sleep:
Follow a regular sleep schedule. Have a routine bedtime and wake up at roughly the same hour each morning.
Sleep in loose, comfortable clothes in a comfortable bed.
Eliminate any sources of noise or bright lights that prevent or disrupt sleep. If noise from outside your bedroom can't be eliminated, it might help if you drown out that noise by creating a monotonous noise of your own. Use a fan, a channel with static noise on your radio, or a recording of ocean waves to make a noise that can lull you to sleep.
Maintain a comfortable temperature in your bedroom
Cut down on beverages containing caffeine during the day, since the stimulating effects of caffeine can last for many hours
Avoid heavy meals before bedtime
Eliminate alcohol, since many people experience wakefulness as the effect of the alcohol wears off
Exercise daily, preferably early in the day
If you read before bed, do this in a chair or in another room
Consider sleeping in a separate bed or separate room if your partner keeps you awake
If you have chronic insomnia because of chronic pain, medical illness or psychiatric problems, seek prompt treatment for your health problem. Don't assume that insomnia is an unavoidable part of your illness.