Not refunding holding deposit

Hello , new to the UK from Canada and need to know if what happened to me is legal. I paid a holding deposit on a rental home , and due to a technicality my referencing came back demanding a guarantor.
Being new here this took a few days but I did find one that qualified. Whilst this was occurring and I was in communication every day with landlords agent , they restarted viewing the property and subsequently signed an agreement with someone else and are now refusing to refund my Holding deposit.
Is this legal , doesn’t make sense to me
Need help