Summarize this article in one sentence.
Educating yourself about the causes of nightmares and the ways in which to prevent them can help you successfully cope with and manage your nightmares. As a result, you may find that you are less stressed as a result of missing sleep or disturbing images and can get the sleep your body needs.  Nightmares are often caused by stress, anxiety, trauma, and physical and mental illness. In some cases, doctors don't know what causes nightmares.  Although nightmares can seem harmless, they can actually significantly affect you and your ability to function because these scary dreams are disrupting vital sleep time.  Most nightmares occur about 90 minutes after you go to sleep and this pattern can continue throughout the night, significantly impacting your ability to relax and get much-needed rest. You may find that keeping a dream diary can help you learn about the source of your nightmares. Any time you wake up from a nightmare, write down what caused the disruption in your sleep and any other factors such as diet or alcohol that may exacerbate scary dreams. Over time, you may notice patterns that can help you take concrete steps to reduce or prevent nightmares.  Place a small notebook and pen next to your bed so that you can write as soon as you wake up. If you don't like writing, keeping a small voice recorder next to you can be a good alternative.  Take your dream diary to any doctor's appointments you may have to deal with your nightmare. This can provide your doctor clues about what is causing the bad dreams. You need time to switch into nighttime and sleep mode. Giving yourself an hour or more to relax can signal your body and brain that it's time to sleep and may help to reduce or prevent nightmares.  Staying away from electronics including television and devices can help your brain relax and keep it from seeing images that may stimulate nightmares. You may also want to avoid reading anything that is scary, too.  Keep the lights in your home and bedroom dimmed to help signal your body and brain that it is time to wind down.  Consider avoiding exercise within three hours of your bedtime to help your body temperature return to normal and minimize the stimulation of your brain. A fixed bedtime routine can further signal your body and brain that it's time to relax and go to bed. Do anything that helps you relax.  A bedtime routine is an excellent way to reduce anxiety and stress that can cause nightmares and disrupt your sleep.  Reading a light novel with the lights dimmed may reduce stress and anxiety and entertain you while not overstimulating your brain and senses.  Drinking herbal tea such as peppermint, lavender, or chamomile while you read may further relax you and keep you asleep. Take a warm bath to promote relaxation and drowsiness. There is evidence that alcohol and drugs such as marijuana or cocaine can cause nightmares. Limiting or quitting either substance altogether may control or prevent nightmares and help you get a better night's sleep.  Do not drink more than 1-2 alcoholic drinks per day and stay away from any alcohol within three hours of your bedtime.  Drinking caffeine or taking caffeine pills close to bedtime may also cause nightmares. Avoid caffeine within three hours of your bedtime.  If you are having any problems quitting alcohol or drugs, see a doctor who can help formulate a treatment plan to quit. Having a nightlight in your room may help more readily cope with nightmares by helping to re-orient yourself if you suddenly wake up. Choose a light that is a soothing and non-stimulating color such as red or orange. Place the nightlight near your bed if possible. You may also want to add others in your bedroom or other rooms of your home. There is a lot of evidence that stress and anxiety are a primary cause of nightmares in adults. Lowering the amount of stress and anxiety in your daily life may reduce or prevent nightmares and help you get a better night sleep overall, which in turn can improve your ability to function.  Avoid stressful situations as much as possible by removing yourself from them if you can. If not, consider taking a ten-minute walk to help you come down from the situation.  Exercise is an excellent way to control stress and anxiety. Aiming to get at least 30 minutes of exercise most days of the week may help reduce and prevent your nightmares and ensure a full night's rest. Some research has shown that altering the storylines of your nightmares can help you to control and cope with them. Actively switch out terrifying aspects of nightmares with more positive images.  You can work on story lines as soon as you wake up from a nightmare or even during the day. Look into your dream diary and write out new endings or elements to your dream, and remove anything that makes you uncomfortable.  For example, if you dream that a giant sea monster eats you and your family, tell yourself or write in the notebook, “we got on the monster and rode it to a beautiful desert island and learned that the monster was a great entertainer.” If you find that nothing alleviates your nightmares or they are severely disrupting your ability to sleep, see your doctor. She may be able to identify the cause of the dreams including stress, medications, or illness.  Take your dream diary with you to help your doctor better assess the situation. Your doctor will likely ask you a series of questions to help her understand when the nightmares started and what factors may contribute to them. Your doctor may suggest you see a psychologist or sleep specialist to help manage or cure your nightmares.  She may also prescribe medication to control nightmares.

Summary:
Learn about nightmares. Keep a dream diary. Wind down early to relax yourself. Establish a pre-bed ritual. Limit or cut out alcohol and drugs. Illuminate a nightlight. Reduce stress and anxiety. Alter nightmare storylines. See a doctor.