Most people require 6-8 hours of uninterrupted REM sleep. Not getting this can lead to many health issues and the body is incapable of repairing itself without this deep sleep. The first thing to think of if you wake up after a few hours is consider what you ate before going to sleep. Many of the culprits such as sugar, alcohol, spicy foods or caffeinated beverages will disturb the gut and lead to blood sugar imbalances that will cause this type of insomnia. So, avoid eating these things in the evening.
An important thing to consider is the conversion of tryptophan, an amino acid, to serotonin. Without this conversion, you will wake up in the middle of the night. It has been found that vitamin B6 is essential for this conversion and that the mineral zinc is important as well. Without these, you will not sleep. A quick note about zinc, many toxic plasticizer, which can be found in some contaminated foods, will block the beneficial effects of zinc. So, changes in the diet, proper detoxification, and using the far infrared sauna would be helpful.
Lastly, without balancing the gut, you will never accomplish proper sleep. About 95% of your serotonin is manufactured in your gut. Having a persistent leaky gut, will allow inflammatory changes to occur in the gut, the brain, damage the blood brain barrier, and interfere with proper production of serotonin and melatonin. Again, leading to insomnia. This is only some of the things that affect our sleep and relying on sleep aids such as melatonin and pharmaceutical compounds exclusively is not the best way to address insomnia in the long run. There may also be side effects to this medicine as well.