It is narrated from Sayyiduna al-Bara' bin Azib (may Allah be pleased with him) that a man complained to the Messenger of Allah (peace and blessings be upon him) of the fear of loneliness, so he (peace and blessings be upon him) said: "Say: 'Subhana al-maliki al-quddus, rabbi al-mala'ikati wal-ruh, jallalta al-samawati wal-arda bil-izzati wal-jabarut' (Glory be to the King, the Most Holy, Lord of the angels and the Spirit; You have covered the heavens and the earth with might and overpowering majesty)." So the man said it, and Allah, the Mighty and Majestic, removed that fear from him.
Hadith Referenceالمعجم الكبير للطبراني / باب الباء / 1160