Insomnia accounts for more than 5.5 million visits to family physicians each year. Although behavioral interventions are the mainstay of treatment, pharmacologic therapy may be necessary for some patients. Understanding the risks and benefits of insomnia medications is critical. Controlled-release melatonin and doxepin are recommended as first-line agents in older adults; the so-called z-drugs (zolpidem, eszopiclone, and zaleplon) should be reserved for use if the first-line agents are ineffective. For the general population with difficulty falling asleep, controlled-release melatonin and the z-drugs can be considered. For those who have difficulty staying asleep, low-dose doxepin and the z-drugs should be considered. Benzodiazepines are not recommended because of their high abuse potential and the availability of better alternatives. Although the orexin receptor antagonist suvorexant appears to be relatively effective, it is no more effective than the z-drugs and much more expensive. Sedating antihistamines, antiepileptics, and atypical antipsychotics are not recommended unless they are used primarily to treat another condition. Persons with sleep apnea or chronic lung disease with nocturnal hypoxia should be evaluated by a sleep specialist before sedating medications are prescribed.