When you rise, O’ Muslim, for the service of prayer, face the direction of the Kaʿbah wherever you are, in both the obligatory and supererogatory prayers.
The Muḥaddith, al-Albānī [d. 1419H], may Allah have mercy upon him, wrote:1
1. When you rise, O’ Muslim, for the service of prayer, face the direction of the Kaʿbah wherever you are, in both the obligatory and supererogatory prayers. This is one of the integral elements of ṣalāh; without it, prayer is invalid.
2. The obligation to turn one’s face towards the qiblah is waived when a warrior must observe ṣalāt al-khawf2 and engage in severe fighting.
In addition, it is waived if one is incapable of facing the qiblah, such as the gravely ill, or those abroad on a ship, a vehicle, or a plane should they fear the time of prayer will end.
It is waived if one offers the supererogatory or wiṭr prayer on a riding animal or some other vehicle. If possible, however, it is recommended that he steer it towards the qiblah for the initial takbīr. Afterward, he may turn it in whatever direction he was heading.
3. When the Kaʿbah is in sight, it is obligatory upon all to face it itself. If one cannot see it, however, he must face its direction.
Ruling: Praying in a Direction Other than That of the Kaʿbah by Mistake
4. If a person does not pray towards the qiblah because of a cloudy sky or some other reason, after having exercised effort in determining the true direction, his prayer is valid and he does not pray again.
5. However, if someone he holds to be trustworthy approaches him while he is praying and informs him of the correct direction, he must face it immediately, and his prayer remains correct.
 Al-Albānī [d.1419H], Talkhīs Ṣifat Ṣalāt al-Nabī, (ﷺ) [al-Maktab al-Islāmī, 5th ed. (1404), 7].  The Fear Prayer.