Praise be to Allah.
Taraaweeh prayer is Sunnah mu’akkadah (a confirmed Sunnah) which the Prophet (peace and blessings of Allaah be upon him) encouraged when he said: “Whoever prays at night in Ramadaan out of faith and the hope of reward, his previous sins will be forgiven.” Narrated by al-Bukhaari, 37; Muslim, 759.
The Prophet (peace and blessings of Allaah be upon him) led his companions in praying Taraaweeh for several nights, then he feared that it may be made obligatory for them, so he did not go out to them. Then ‘Umar united the people under one imam, and it has been prayed in congregation ever since. It was narrated that Ismaa’eel ibn Ziyaad said: ‘Ali passed by the mosques in which there were lamps during the month of Ramadaan and said, ‘May Allaah illuminate ‘Umar’s grave for him as he illuminated our mosques for us.” Narrated by al-Athram, quoted in al-Mughni, 1/457.
Al-Bahooti said in Daqaa’iq Uli al-Nuha, 1/2245:
It is better to pray Taraaweeh in the mosque than at home, because the Prophet (peace and blessings of Allaah be upon him) gathered the people to pray Taraaweeh for three consecutive nights, as was narrated by ‘Aa’ishah… and he (peace and blessings of Allaah be upon him) said: “Whoever prays qiyaam with the imam until he leaves, it will be as if he spent the whole night in prayer.”
Al-Shawkaani said in Nayl al-Awtaar (3/62): Al-Nawawi said: The scholars are agreed that it is mustahabb, but they differed as to whether it is better to pray it alone at home or in congregation in the mosque. Al-Shaafa’i and a number of his companions, and Abu Haneefah, Ahmad, some of the Maalikis and others said that it is better to pray it in congregation as ‘Umar ibn al-Khattaab and the Sahaabah (may Allaah be pleased with him) did and as the Muslims continued to do, because this is one of the manifest rituals.
So praying it in congregation in the mosque is better, but if a man prays it on his own at home, or in congregation with his family, that is permissible.
Al-Nawawi said in al-Majmoo’, 3/526:
Taraaweeh prayer is Sunnah according to scholarly consensus… it is permissible to pray it alone or in congregation, but which is better? There are two well-known points of view concerning this; the correct view according to the consensus of the Sahaabah is that it is better to pray it in congregation.
And Allaah knows best.