I have also been here too many times to count.
My take on it is that it's not a failure as long as you've learned something.
In my case, for the first number of projects I built that nobody bought/wanted, I didn't learn to find the market first (sadly), but I did learn a huge amount about how to build things.
Now I can build better things faster - but I'm actively learning to find the market.