Yeah, I have experienced something like this, and ultimately (after trying like every fucking thing, including quitting smoking (the first onset of it was 15 years ago when I still smoked), quitting alcohol, running and weightlifting during the day, "natural" supplements (melatonin, L-tryptophan, 5-HTP), more sex, less sex, vegetarian diet, meaty "paleo" diet, and a bunch of other shit) I indeed started taking zolpidem (Ambien) whenever I'd had a few bad nights of sleep in a row, and didn't feel like I could tolerate another one.
It did work, for over a decade, for me. I also didn't want to take it though, so I seldom took it more than four times in a month, and often went a few months without any.
In my case, bouts of this kind of insomnia (tired, feel like I might be able to sleep but just can't) happen seemingly at random, every few months, and not connected to any identifiable stressor. (I feel like it might be more likely to experience another insomnia episode when work is too hectic or I have some kind of stressful situation going on, but it definitely also happens when everything is fine). They last days or weeks.
I'd never been able to fall asleep easily (was a night person from high school onward) but I was able to sleep in late once asleep. This changed about 12 years ago, in my early 30s, where I had the first episode of real insomnia. I couldn't sleep well for a week, laying in bed from 23:00 to 3:00, 4:00, finally 7:00 AM.
I visited over 10 sleep specialists and doctors (this was in Tokyo, Japan). They gave various conflicting advice, all of which I tried, but nothing worked for me but the drugs. (I tried a bunch of different drugs, but ultimately zolpidem was the one that, of those that pretty much guaranteed I would be able to sleep, had the fewest noticeable side effects.
Recently my doctor instead prescribed me etizolam, which is a thienodiazepine (but basically, a benzodiazepine), and this also works. I prefer this one because, for me at least, zolpidem causes a kind of drunk/high/bad-judgement "I'm on drugs" feeling and has scary stories about people doing stuff they don't remember later.
Etizolam (1mg for me) relieves the insomnia without the druggie feeling. (It does make you feel good though, and I suspect there is a high risk of dependency if you take it every day.)
After taking a keen interest in this topic over many years (just for the obvious, selfish reasons) I think there are probably many reasons this can occur, and YMMV. But I have never gotten any of the non-drug "remedies" to work.
Even months/years of a heavy exercise regimen, like barbell weight-lifting — which definitely helps me sleep longer and better in general — doesn't seem to have any effect on these episodic bouts of insomnia.
From that standpoint, the drugs have helped me manage it. I never have a full week of bad sleep any more, and eventually each episode of insomnia goes away on its own.