All perfect praise be to Allah, The Lord of the Worlds. I testify that there is none worthy of worship except Allah, and that Muhammad is His slave and Messenger.
Facing the Qiblah (i.e. the direction of the Ka‘bah in Makkah) is one of the conditions for the validity of prayer that must be fulfilled, and there is no room for personal reasoning to determine the direction of the Qiblah for someone who is in an urban area because he is able to know the correct Qiblah direction with certainty.
Ibn Qudaamah said in Al-Mughni: “As for a person who is able to see (not-blind), if he prays towards a direction other than the direction of the Ka‘bah in an urban area and then finds out that it was wrong, it is obligatory on him to repeat the prayer, whether or not he had asked someone about the Qiblah direction, because urban areas are not suitable for personal reasoning to determine the Qiblah. He can find the direction by looking at the niches in mosques and prayer areas, and he can usually find someone to inform him of the correct Qiblah direction with certainty. Therefore, he is not entitled to try to determine the Qiblah direction based on his personal reasoning, just like a person who has access to Sharee‘ah texts on religious rulings cannot opt for independent reasoning. So if he prayed without finding proof of the direction of the Qiblah and then found out that he prayed in the wrong direction, it is obligatory on him to repeat that prayer because of his negligence. If someone informs him of a direction and it turned out to be wrong, then he has misguided him and it becomes evident that his guidance is not proof.” [End of quote]
As long as you are in an urban area, then you are able to find out the correct direction of the Qiblah and ask someone to inform you of it. If you did not ask anyone and prayed towards a random direction, your prayer is not valid because of your negligence and failure to perform due diligence, and it is incumbent on you to repeat the prayer. Ibn Qudaamah said in Al-Mughni: “If he finds someone whom he can imitate or who can inform him of the correct Qiblah direction but fails to imitate him or ask him about it, or if he acted against the guidance of that person who informed him of the direction or the one who did due diligence to determine the direction and prayed anyway, his prayer is invalid in all these cases.” [End of quote]
Allah Knows best.