"failed by a hair" means the same as "almost sucedeed"?

“failed by a hair” means the same as “almost sucedeed”?

Yes, I think. It likes that it was between him and success a distance equals to one hair