The view of the Hanbali madhhab is that it is makrooh to face the sun or moon when relieving oneself; the reason they gave for this ruling is that there is some of the light of Allah in both of them.
Shaykh Mansoor al-Bahooti (may Allah have mercy on him) said: And it is makrooh (to face the sun or moon) without a barrier when relieving oneself, because there is some of the light of Allah in both of them, and it was narrated that there are angels with them and that the names of Allah, may He be exalted, are written on them.
End quote from Kashshaaf al-Qinaaâ, 1/62
The Hanbali view with regard to this matter is the view of the majority.
Radd al-Muhtaar âala al-Durr al-Mukhtaar, 1/343; Haashiyat al-Bujayrami âala al-Khateeb, 1/196; al-Taaj waâl-Ikleel li Mukhtasar Khaleel, 1/408; al-Mawsooâah al-Fiqhiyyah, 34/9
The second opinion is that it is not makrooh to face the sun or moon when relieving oneself, and this is the correct opinion.
Al-Nawawi (may Allah have mercy on him) said: This is the favoured view, because judging something to be mustahabb requires evidence, and there is no evidence with regard to this matter.
End quote from al-Majmooâ, 2/111
Shaykh Muhammad ibn âUthaymeen (may Allah have mercy on him) said:
The correct view is that it is not makrooh, because of the absence of any sound evidence and because the evidence which indicates that it is permissible is proven.
End quote from al-Sharh al-Mumtiâ by Ibn âUthaymeen, 1/123
And Allah knows best.