Nina Vujovic of Harvard University posits four basic "ways to mess with sleep."
These messes include insomnia, hypersomnia, and unrefreshing sleep.
As a practical matter, brain injuries more often result in hypersomnia than insomnia and the unusual circumstances Vujovic mentions are indeed uncommon and rarely experienced by most people, with the exception of pain, which does often cause poor sleep.
Caffeine - the most common stimulant. Widely used. Seems to block adenosine which makes us sleepy. People use caffeine to stay awake and increase alertness during the day, but of course it makes it tough to fall asleep sometimes.
That is a very broad statement, and tolerance for caffeine varies greatly from person to person depending on brain chemistry and history of consumption.
Some people feel an effect from caffeine but it does not stop them from sleeping well. Indeed, stimulants help some people sleep.
Nicotine - the other most common stimulant. Widely used through tobacco. The stimulant effect may keep people from falling asleep and the withdrawal symptoms prompt some heavy smokers to wake up earlier than they would otherwise.
Nicotine also shifts some of the sleep architecture from deep and REM sleep toward light sleep. In this way it acts somewhat like alcohol, even though alcohol is a depressant. Alcohol can cause sleep maintenance insomnia. Even more than with caffeine, the effect of alcohol varies greatly from person to person and depends on time of consumption, amount consumed, social milieu, and other food and drink consumed. But there is no question alcohol is often a culprit in disturbed sleep and doctors inquire about drinking when investigating sleep disorders. Alcohol also makes snoring and apnea symptoms worse.
Prescription medications and recreational drugs can also disrupt sleep. Look at the warnings or extended labels on medicines and you will often find sleeplessness listed as a potential side effect. Over-the-counter medicines, too. Sometimes you will see both drowsiness and sleeplessness listed. That might sound paradoxical to someone who doesn't have experience in sleep science, but it is common. Different people react differently. Illegal drugs disrupt sleep, too. They often have powerful effects on the nervous system, which is part of why people use them, but the short-term pleasure sometimes comes with longer-run sleep disruption. Another problem is that these illegal drugs can be adulterated with other materials and the purity and therefore dosages can vary greatly.
Light is effective as a means of maintaining wakefulness - even the Air Force uses it to keep pilots alert - and light therapy is used in treatment of circadian disorders. However, too much light can prevent sleep onset or cause early awakening.
The proliferation of electronic devices in the household has raised a new problem for sleepers prone to light disruption. Televisions, computer screens, and the like give off light that makes it tough for some to sleep. People who study this problem refer to “electronic entertainment and communication devices (EECDs)”. Electronic games are particularly bad. The combination of a task that never ends, a seemingly infinite array of internet options and content, and a light shining directly into the eyes of the human players make games insidious.
Researchers at the University of Alberta found that kids with too much access to EECDs had "shortened sleep duration, excess body weight, poorer diet quality, and lower physical activity levels"
Most of the concerns voices about excess consumption of electronic entertainment is pointed at children and teens, but a university survey found adults have problems, too. People who spend excessive time playing electronic games tend to have poor sleep hygiene and spent 1 to 1.6 hours per night less in sleep.
The relationship between pain and sleep is complicated, and depends partly on the source of the pain, severity, location in the body. Pain can make It hard to get to sleep, but it also encourages the brain to stay asleep as sleep provides a respite. The regeneration in the body that occurs during deep sleep can mitigate some pains. Medication for severe pain (opioids) make you sleep.
Menstruation can also cause sleep problems, as can menopause separate from the general decline in sleep quality with age. Noise can be a disruptor, although white noise helps some people sleep.
Exercise is one of those things that comes in many forms and which has different effects on sleep quality and quantity in different people.
Generally, we can say
1) Daytime exercise - good for sleep
2) Evening exercise (say after work, but before dinner) - good for sleep
3) Nighttime exercise in the couple hours before bedtime - bad for sleep.
These are generalizations, of course, and some people have no problem with night exercise, the same way some people have no problem with consuming caffeine before sleep.
Daytime exercise can cause insomnia in some people - the stimulation makes it hard to calm down at bedtime.
Even more generally:
1) Weight-lifting and similar work of large skeletal muscles - good for sleep, promotes deep sleep
2) Hard aerobic exercise - often results in sleep maintenance insomnia the following night
3) Easy aerobic exercise - mild beneficial effect on sleep
Many people report sleeping better after they start a running or jogging regimen, but some of this could be due to spending time outdoors and in sunlight.