The harder you chase sleep, the further away it moves
There is a particular kind of night where you decide, firmly, that you are going to sleep. You close your eyes with intent. You check the clock to see how much time is left. And you are still awake an hour later, more alert than when you started.
That is not a personal failing and it is not a sign that you are bad at sleeping. The effort itself is the problem. Trying to sleep is arousing, which is why a determined night so often goes worse than a relaxed one.
Sleep is one of the few things that does not respond to being chased. It arrives when you stop watching for it. The moment you start monitoring whether it is working, you have given your brain a job, and a brain with a job stays awake to do it.
This is well known enough in sleep treatment that there is a name for the fix. Paradoxical intention asks you to try to stay awake instead, on purpose, without a screen and without moving. It sounds like a trick because it is one, and it works for the same reason the effort was the problem.
Your body cannot tell the difference between a real danger and a night that is going badly. It reads both through the same signals, and all of these are signals.
The aim is to take the job away from your brain, and the most reliable way to do that is to stop lying there working on it.
If you have been awake for what feels like a while, get up. Not to punish yourself, and not to do anything interesting. Keep the lights low, leave the phone alone, and do something dull and quiet somewhere other than your bed. Go back when you actually feel sleepy rather than when you have decided you should be.
The point of leaving is not the activity. It is that your bed stops being the place where you lie awake trying.
Use your bed for sleep and not for trying. If you can hold to one thing from all of this, hold to that. A bed that has become the place you wrestle with the night is a bed that will keep reminding you of it.
One bad night changes very little. What makes a run of bad nights is the fear of them building up, and the fear is fed by the effort. Let the night be bad, and it tends to be shorter.
Peakora has a guide to what to actually do once you have woken, and eight soundscapes for the hours when the room itself is the problem.