What the tradition describes, and what the research licenses
Look at what the second half of the report below actually describes. Not a feeling of community in general. A specific, repeatable gathering, in a set place, with a stated activity that carries the time. That is a far easier thing for a lonely person to walk into than an instruction to make friends. And below it, the honest picture from the research about which levers move.
Qur’an and Sunnah
وَٱصۡبِرۡ نَفۡسَكَ مَعَ ٱلَّذِينَ يَدۡعُونَ رَبَّهُم بِٱلۡغَدَوٰةِ وَٱلۡعَشِيِّ يُرِيدُونَ وَجۡهَهُۥۖ وَلَا تَعۡدُ عَيۡنَاكَ عَنۡهُمۡ تُرِيدُ زِينَةَ ٱلۡحَيَوٰةِ ٱلدُّنۡيَاۖ وَلَا تُطِعۡ مَنۡ أَغۡفَلۡنَا قَلۡبَهُۥ عَن ذِكۡرِنَا وَٱتَّبَعَ هَوَىٰهُ وَكَانَ أَمۡرُهُۥ فُرُطࣰ ا
Content yourself with those who pray to their Lord morning and evening, seeking His approval, and do not let your eyes turn away from them out of desire for the attractions of this worldly life: do not yield to those whose hearts We have made heedless of Our Quran, those who follow their own low desires, those whose ways are unbridled
Qur’an 18:28
Abu Huraira reported Allah's Messenger (ﷺ) as saying:He who alleviates the suffering of a brother out of the sufferings of the world, Allah would alleviate his suffering from the sufferings of the Day of Resurrection, and he who finds relief for one who is hard-pressed, Allah would make things easy for him in the Hereafter, and he who conceals (the faults) of a Muslim, Allah would conceal his faults in the world and in the Hereafter. Allah is at the back of a servant so long as the servant is at the back of his brother, and he who treads the path in search of knowledge, Allah would make that path easy, leading to Paradise for him and those persons who assemble in the house among the houses of Allah (mosques) and recite the Book of Allah and they learn and teach the Qur'an (among themselves) there would descend upon them tranquility and mercy would cover them and the angels would surround them and Allah mentions them in the presence of those near Him, and he who is slow-paced in doing good deeds, his (high) lineage does not make him go ahead
Sahih Muslim 2699graded sound, sahihaynfull report
Translation: M.A.S. Abdel Haleem, The Qur'an, Oxford University Press, 2004.
What the research says
Masi CM, Chen HY, Hawkley LC, Cacioppo JT (2011). A meta-analysis of interventions to reduce loneliness. Personality and Social Psychology Review, 15(3), 219 to 266 doi
The authors sorted loneliness programmes into four kinds: teaching social skills, adding social support, creating more chances to meet people, and working on how a person reads social situations. Across the trials with a comparison group, the last of those did best and simply creating chances to meet people was the weaker lever. The authors also note that effects looked much larger in studies with no comparison group than in the randomised ones.
Hickin N, Kall A, Shafran R, Sutcliffe S, Manzotti G, Langan D (2021). The effectiveness of psychological interventions for loneliness: a systematic review and meta-analysis. Clinical Psychology Review, 88, 102066 doi
A newer pooling of psychological approaches to loneliness, finding a moderate reduction on average. The authors flag that the trials varied a great deal in quality and that loneliness was often measured as a side outcome rather than as the thing the trial set out to change.