Even if you sleep like a baby most nights, you’ve probably had at least the occasional bout of insomnia. Whether it’s that late-night snack that keeps the sandman away, stress or something less sinister, here are six relaxation techniques to try when sleep eludes you:

1. Guided visualization

Lie in bed and tell your body to relax from head to toe, suggests Joshua Jacobi, MD, an interventional cardiologist in Pasadena, California. “Forehead relax, eyes relax, cheeks relax,” and so forth down until your toes. “Then, I picture lying on a beach. I bring in all the sensory awareness to the setting. So I feel the sand in my toes, the warmth of the sun, a cool breeze. I see the waves slowly coming in to the shore. I see palm trees waving in the wind. I hear the sound of the waves as they come in,” says Jacobi. Picture this scene or something else that is relaxing for you.

2. Alternate Nostril Breathing

Alternate Nostril Breathing encourages deep relaxation by balancing the left and right sides of the brain while calming the nervous system, says Amita Patel, founder of Aligned Holistics, a coaching services company that combines nutrition, physical activity, relationships, career and personal philosophy.

The practice, known in Sanskrit as Nadi Shodhana Pranayama, has made headlines recently after Hillary Clinton wrote in her new book that Alternate Nostril Breathing helped her cope with her anxiety after her loss to Donald Trump in the 2016 presidential election. She even demonstrated the technique for Anderson Cooper on CNN.

If you want to practice it for yourself, here’s how: Rest your right ring finger and thumb on either side of your nostrils, lightly touching them. Take a big breath in and a big breath out, then close off the right nostril with your thumb and inhale through the left nostril for a four count. At the top of that breath, close off the left nostril with your ring finger, hold and retain for a count of four, and then release the right nostril and exhale for four. Repeat as many cycles as comfortable until relaxed ending with the left nostril, recommends Patel.

3. Analyze your sleep cycle

Take a page from the Quantified Self movement and start recording your sleep data, says Ari Meisel, founder of Less Doing More Living, a productivity hack blog for optimizing, automating and outsourcing everything in your personal and professional life from fitness to email management.

Sleep sensors, such as Beddit Smart or Fitbit Charge 2, can monitor things like heart rate and skin temperature so you can get an incredible level of insight into the way you move through your various sleep cycles (light sleep, deep sleep, REM). “While your perceived level of exhaustion may have you convinced you are getting no sleep at all, a pattern most likely will emerge,” says Meisel. Once you identify that pattern, exploit it. “Simply knowing that you average three-hour stints instead of the 15 minutes you thought you were getting can be a huge psychological windfall.”

4. Treat your anxiety

woman sitting up in bed with insomnia If anxiety is keeping you awake, try yoga, and if that doesn't work, consider prescription medication. (Photo: Stokkete/Shutterstock)

CureCrowd, the first search engine to visually rate treatments and remedies for medical conditions by crowdsourcing the experiences of real but anonymous patients, found that users rated marijuana more highly than Ambien to treat anxiety and sleeplessness. Other remedies included exercise, yoga and prescription antidepressant/antianxiety meds.

5. Count backward

While lying in bed, start counting backwards from 100. Do it slowly, about once a second, 100...99...98. Take your time. “The trick is this: If you get lost or forget what number you're on, you need to start over again from 100. Every time you get lost, gently start over. Don't allow yourself to become frustrated, just be gentle with yourself and start back over from 100,” says Phillip Mandel, a hypnotherapist in Beaverton, Oregon. Why does it work? It’s both monotonous and mildly hypnotic. “Note that it's not hypnosis in the usual sense, such as 'you are getting sleepy'. Rather, you're just doing something monotonous with your mind that will have the effect of making you sleepy,” says Mandel.

6. Guided imagery

“Guided imagery, a close cousin of meditation and hypnosis, can shift brain wave activity, and specific images can be learned that promote the brain's movement toward deep, restful sleep,” says Leslie Davenport, a psychotherapist and author of “Healing and Transformation through Self-Guided Imagery.”

To try it, imagine a small ball of yarn. See this ball of yarn as holding the last bit of residual tension you have. Find the tip of the yarn and watch as the ball begins to roll slowly, unwinding as it moves. See the strand of yarn unfurling and resting on the floor, becoming longer as it continues to roll slowly. “Sense the decompressing. Feel the spaciousness around it now,” says Davenport. “As you watch the yarn, feel also the unwinding of any residual tension within you. Like tiny muscle fibers softening, watch as the ball continues to release from its very core, the soft yarn now stretched out, open, and completely at rest.”

Of course, this list is just a sampling. Other relaxation techniques include Progressive Muscle Relaxation, which involves tensing and relaxing each major muscle group to create awareness of tension and relaxation; somatic exercise, in which gentle, soft stretching and movements are done while lying on a mat to help shift your central nervous system to create new muscular habits that alleviate pain and tightness. And finally pandiculation, a brain reflex action pattern similar to how a dog gets up from rest, putting his front paws out and lengthening his back as he relaxes his belly. Pandiculation can wake up the muscular system at the brain level and provide deep relaxation. One or more of these may help you find that elusive 40 winks.

Editor's note: This story has been updated since it was originally published in April 2014.