There’s a lot of evidence that exercise affects your sleep. But the exact effect seems to depend on what exercises you do and when you do them. For instance, a brisk walk after work can help you doze off faster at night and sleep more soundly. But if you postpone your walk until the late evening, you might find yourself tossing and turning in bed. Timing Is Everything So, why does the timing of your workout matter? It’s simple: Your body temperature goes up during exercise and then drops off afterward. This post-exercise dip is beneficial because the cooler your body temperature is, the more likely you are to feel sleepy. The catch is it may take up to six hours for your body temperature to fall. So if you want to maximize the sleep benefits of exercise, it’s best to work out five to six hours before going to bed, according to the National Institute of Neurological Disorders and Stroke. If that isn’t possible, however, don’t worry about it. Exercising at other times of day is still great for your overall health. Just try to avoid working out during the last couple of hours before bedtime so you aren’t wide awake when you should be getting drowsy. Working Out Sleep Problems You don’t have to exhaust yourself to reap the reward of better sleep. In fact, moderate-intensity aerobic activities—such as walking briskly or cycling on level ground—seem to be particularly beneficial to a good night’s rest. One study that proved this included more than 400 sedentary, overweight postmenopausal women. Typically, 35 to 60% of women in this age group say they have sleep problems. The women in the study were randomly assigned to one of four groups: three groups did various amounts of moderate exercise and one control group did no exercise. After six months, the exercisers reported sleeping better since becoming active. The more they exercised, the greater the benefits. But sleep was improved even in those who worked out less than health guidelines recommend. Sleep Happy One way exercise may help you sleep is by giving your mood a boost. Exercising regularly helps ease stress, anxiety and depression—all problems that can interfere with getting a restful night’s sleep. Staying physically active is also crucial for taking charge of your weight. Being overweight increases your risk of developing sleep apnea, a common disorder that leads to little pauses in your breathing while you snooze. These little pauses can stir you from deep sleep into lighter sleep. Repeated throughout the night, they can wreck the quality of your sleep and leave you tired the next day. If you’re overweight and have sleep apnea, losing even a few pounds through regular exercise and heathy eating helps improve your slumber. Sleep Improves Exercise, Too Interestingly, the relationship between exercise and sleep is a two-way street. When you get enough sleep, you’re more likely to feel motivated to exercise the next day. In one small study, women with insomnia tended to shorten their workouts after nights when they had trouble dozing off. Sleep loss may make you feel as if you’re working harder and getting tired sooner during exercise. Plus, if you play sports, sleep loss may throw off your game. On the flip side, getting plenty of sleep might improve your athletic performance. Researchers found that when Stanford basketball players got extra sleep, they had faster sprint times and made a higher percentage of free throws and three-pointers. Sleeping and exercising are two of the best things you can do for your body. Regular physical activity helps you sleep, and sleeping well helps you stay active. It’s a positive cycle that can enhance your life in multiple ways. Key Takeaways When you work out and what exercises you do can affect your sleep—for better and worse. If you want to maximize the sleep benefits of exercise, it’s best to work out five to six hours before going to bed. Moderate-intensity aerobic exercises, such as brisk walking, seem to be best for getting a good night’s sleep. The sleep-exercise connection goes both ways: When you get enough sleep, you’re more likely to feel motivated to exercise the next day. Remember to talk to your doctor before beginning or revising an exercise program.