Allah's Messenger (ﷺ) said, "If anyone of you goes to an open space for answering the call…

Sahih al-Bukhari Book 4 Hadith 10

Sahih al-Bukhari #144

Ablutions (Wudu') 4:10

Narrated Abu Aiyub Al-Ansari:

Allah's Messenger (ﷺ) said, "If anyone of you goes to an open space for answering the call of nature he should neither face nor turn his back towards the Qibla; he should either face the east or the west."

Chapter: While urinating or defecating, never face the Qiblah except when you are screened by a building or a wall or something like that

Grade: Sahih