The Prophet ﷺ forbade solitude, that a man should spend the night alone or travel alone.
أن النبي ﷺ نهى عن الوحدة: أن يبيت الرجل وحده، أو يسافر وحده.
Ahmad narrated it (5650) from Abu Ubayda Haddad, from Asim bin Muhammad, from his father, from Ibn Umar, and he mentioned it. Its chain is sahih. Abu Ubayda Haddad is Abdul-Wahid bin Wasil Sadusi, their mawla, from Basra, a resident of Baghdad, thiqah (trustworthy), and he is among the narrators of Bukhari.Ibn Umar has two hadiths, one of them the prohibition against traveling alone, and the second the prohibition against spending the night alone and traveling alone. A group among the students of Asim bin Muhammad, whose father was the son of Zayd bin Abdullah bin Umar bin Khattab, and who is one of the narrators accepted by all the major hadith compilers, mentioned the prohibition against traveling alone, while Abu Ubayda mentioned the second one.The wisdom behind the prohibition against spending the night alone is that Satan whispers into his heart.