It's good for a good ending to be at least a little bittersweet, but total failure of all the heroes is hardly realistic. If the hero hasn't learned how to successfully solve the problem because the author doesn't have an answer, then why even bother me? And I've always detested the Chinese-film-style where everything goes wrong at the last moment for basically no reason.
Some genres are better suited to loss around the ending. In War movies, everyone usually dies except possibly the protagonist who is the sole survivor who tells the story. Many westerns end in partial tragedy, if for no other reason than that once the hero has defeated the villains, there's no reason for them to stay in the healed town. Classic noirs almost always end with the death of one of the lead characters, usually the detective.
But like the others said, you need to communicate the kind of story you're telling pretty early on. Nobody would be happy if My Little Pony was suddenly a serious war story (in the main show, anyway) where everyone dies in the final episode.