Yes, it is wrong to be alone all the time. Since the Prophet ﷺ warned against it. Rather one should spend some time alone and some time in beneficial company.
عَنِ ابْنِ عُمَرَ، عَنِ النَّبِيِّ صَلَّى اللهُ عَلَيْهِ وَسَلَّمَ، قَالَ: لَوْ يَعْلَمُ النَّاسُ مَا فِي الوَحْدَةِ مَا أَعْلَمُ، مَا سَارَ رَاكِبٌ بِلَيْلٍ وَحْدَهُ
Ibn Umar (May Allah Most High be pleased with them both) narrated that the Prophet ﷺ said, ‘If the people knew what I know about being alone, then nobody would ever travel alone at night.’ (Sahih al-Bukhari, 2998).
Although a person should spend some time alone in order to worship, reflect, study or engage in other beneficial practices. It is contradictory to the Islamic teaching for a person to remain alone all the time, or for the vast majority of one’s time.
Such behavior can have a detrimental effect upon an individual’s well-being. Including one’s mental health. Therefore, Muslims should give it due consideration.
In Islam we are encouraged to be moderate and balance everything. So, although spending time alone is very beneficial and even necessary for spiritual growth. To go beyond moderation can be harmful and has been warned against in the Sunnah of the Prophet ﷺ.
عَنِ ابْنِ عُمَرَ، أَنَّ النَّبِيَّ صَلَّى اللهُ عَلَيْهِ وَسَلَّمَ نَهَى عَنِ الْوَحْدَةِ، أَنْ يَبِيتَ الرَّجُلُ وَحْدَهُ أَوْ يُسَافِرَ وَحْدَهُ
Ibn Umar (May Allah Most High be pleased with them both) said, ‘The Prophet ﷺ prohibited being alone. And for a man to sleep in a house alone or travel alone.’ (Musnad Ahmad, 5650).
In Majma al-Zawaid Imam al-Haythami confirmed that this Hadith has sound narrators:
رَوَاهُ أَحْمَدُ، وَرِجَالُهُ رِجَالُ الصَّحِيحِ
It was narrated by (Imam) Ahmad, and the narrators are the narrators of Sahih. (Majma al-Zawaid 13208, Imam al-Haythami).
Due to the authentic Hadith narrations above, Muslims should organise their lives in such a manner that they are not alone all the time. It is obligatory to spend time with close relatives. However, it is also recommended to spend time in the company of people whom one can benefit from.
The Muslim community should arrange regular gatherings that people can attend and benefit from, whilst spending time with like-minded Muslims. These events could be religious classes, gatherings of Dhikr or other meetings.
And Allah Most High Knows best.
-Answered by Shaykh Noorud-deen Rashid (20.07.2022)
Are there things in Islam that help with depression?
Is the Hadith about not sleeping in a house alone Sahih?
See also video: