Praise be to Allah.
Yes, it is proven that the Prophet (peace and blessings of Allaah be upon him) forbade that in several ahaadeeth, including the following:
It was narrated from Ibn ‘Umar (may Allaah be pleased with him) that the Prophet (peace and blessings of Allaah be upon him) said: “If people knew what I know about being alone, no rider would travel at night by himself.” Narrated by al-Bukhaari (2998).
Imam Ahmad narrated this hadeeth in al-Musnad (2/91) with some additional material in which it says:
The Prophet (peace and blessings of Allaah be upon him) forbade being alone, for a man to spend the night alone or travel alone.
But this report is regarded as shadhdh (odd), and it is superseded by the report of al-Bukhaari for two reasons:
(a)The report of al-Bukhaari was narrated by nine of the companions of ‘Aasim ibn Muhammad ibn Zayd ibn ‘Abd-Allaah ibn ‘Umar from his father from Ibn ‘Umar, all of whom mention travelling only and not spending the night. Only one of the students of ‘Aasim ibn Muhammad, namely ‘Abd al-Waahid ibn Waasil, mentioned the prohibition on spending the night alone. Although he was thiqah (trustworthy), the report narrated by many thiqaat supersedes his report .
(b)This is indicated by a similar report from Ahmad, although the narrator does not mention the specific wording of the Prophet (peace and blessings of Allaah be upon him), unlike the report of the majority.
Hence the editors of Musnad Ahmad (9/467), and Shaykh Muqbil al-Waadi’i in Ahadeeth Mu’allah (249), ruled that the report of ‘Abd al-Waahid is shaadh (odd), unlike Shaykh al-Albaani who ruled that it is saheeh, as stated in al-Silsilah al-Saheehah (60).
The prohibition on spending the night alone was narrated in a mursal report from ‘Ata’, as was narrated by Abu Dawood in Kitaab al-Maraaseel (380) and Ibn Abi Shaybah in al-Musannaf (7/726).
Al-Tabaraani narrated in al-Awsat (2079) via Muhammad ibn al-Qaasim al-Asadi from Zuhayr ibn Mu’aawiyah from Abu’l-Zubayr from Jaabir that the Prophet (peace and blessings of Allaah be upon him) said: “If people knew what I know about being alone, no rider would travel at night by himself and no man would sleep in a house by himself.”
But this report is to be rejected because of Muhammad ibn al-Qaasim al-Asadi, because he was accused of lying.
The prohibition on spending the night alone was also narrated in some saheeh reports. It was narrated that ‘Umar ibn al-Khattaab (may Allaah be pleased with him) said: No man should travel alone or sleep in a house on his own.” End quote.
Classed as saheeh by al-Albaani in al-Silsilah al-Saheehah (1/130).
Imam Ahmad was asked about a man spending the night alone. He said: I prefer him to avoid that. Quoted from al-Adaab al-Shar’iyyah (1/428).
It was narrated from ‘Abd-Allaah ibn ‘Amr ibn al-‘Aas that the Prophet (peace and blessings of Allaah be upon him) said: “The (lone) rider is a devil, two riders are two devils and three are a travelling party.” Narrated by al-Tirmidhi (1674), who said it is a hasan hadeeth. It was also classed as hasan by Ibn Hajar in Fath al-Baari (6/53) and by al-Albaani in al-Silsilah al-Saheehah (62).
These ahaadeeth indicate that it is makrooh to be alone in situations where a man fears for himself because of weakness, severe exhaustion or hardship, or when he fears that the shaytaan may tempt him and mislead him. The benefit of being with righteous companions is not limited to help and support, rather the most important thing is that it helps him to remain steadfast and pious, for the shaytaan is further away from two.
Al-Haafiz Ibn Hajar said in Fath al-Baari (6/53):
Ibn Khuzaymah reported it under the heading; “the prohibition on two travelling and that less than three are sinners,” because what is meant by “devil” is a sinner. Al-Tabari said: This is a rebuke aimed at disciplining and guiding because of the fear of loneliness for one, but it is not haraam. The one who travels alone in the wilderness and the one who stays alone in a house has no guarantee that he will not feel lonely, especially if he had bad thoughts and is weak in faith.
In fact people differ with regard to that and the prohibition concerning that is a measure of protection, but if there is need for that, it should be fine. It was said, commenting on the words “the (lone) rider is a devil” that his travelling alone is suggested to him by the shaytaan, or he is likened to the shaytaan in his actions. And it was said that it is disliked because if the person who is travelling alone dies on the journey, there will be no one who can take care of him; similarly, if two are travelling and both or one die, there will be no one to help, unlike three, because in most cases that fear will not be present. End quote.
The apparent meaning of the hadeeth is that the prohibition applies to the one who travels alone via empty and remote routes. As for well-travelled routes, and those in which there is no risk of being lost, and where there are likely to be helpers and companions, there is no report that it is makrooh or prohibited. The same applies to travelling nowadays on planes, ships and buses, because those who are in them are all regarded as traveling companions, so the one who travels by these means is not alone in the sense that is forbidden.
Shaykh Ibn ‘Uthaymeen said in Fataawa Noor ‘ala al-Darb (mutafarraqaat/al-adaab):
This points to the warning against travelling alone, but that applies to journeys where the route is not travelled by many. As for journeys where the route is travelled by many, and it is as if one is in the middle of a village, such as the route from al-Qaseem to Riyadh, or Riyadh to Dammam and other such routes where there are many travellers, and the road to the Hijaz during the Hajj season, this is not in fact regarded as being alone, because many people travel by these routes. So a person may be alone in his car but he is not alone on the journey, rather there are people around him, behind him and in front of him at every moment. End quote.
Shaykh al-Albaani said in his commentary on this hadeeth in al-Saheehah (62):
Perhaps the hadeeth refers to travelling in the deserts or wilderness where the traveller rarely sees anyone. It does not include travel nowadays on paved and well-travelled roads. And Allaah knows best. End quote.
And Allaah knows best.