Sahih al-Bukhari, Hadith 1803

Narrated Abu 'Is-haq: I heard Al-Bara' saying, "The above Verse was revealed regarding us, for the Ansar on returning from Hajj never entered their houses through the proper doors but from behind. One of the Ansar came and entered through the door and he was taunted for it. Therefore, the following was revealed: -- "It is not righteousness That you enter the houses from the back, But the righteous man is He who fears Allah, Obeys His order and keeps away from What He has forbidden So, enter houses through the proper doors." (2.189)

حَدَّثَنَا أَبُو الْوَلِيدِ، حَدَّثَنَا شُعْبَةُ، عَنْ أَبِي إِسْحَاقَ، قَالَ سَمِعْتُ الْبَرَاءَ ـ رضى الله عنه ـ يَقُولُ نَزَلَتْ هَذِهِ الآيَةُ فِينَا، كَانَتِ الأَنْصَارُ إِذَا حَجُّوا فَجَاءُوا لَمْ يَدْخُلُوا مِنْ قِبَلِ أَبْوَابِ بُيُوتِهِمْ، وَلَكِنْ مِنْ ظُهُورِهَا، فَجَاءَ رَجُلٌ مِنَ الأَنْصَارِ، فَدَخَلَ مِنْ قِبَلِ بَابِهِ، فَكَأَنَّهُ عُيِّرَ بِذَلِكَ، فَنَزَلَتْ ‏{‏وَلَيْسَ الْبِرُّ بِأَنْ تَأْتُوا الْبُيُوتَ مِنْ ظُهُورِهَا وَلَكِنَّ الْبِرَّ مَنِ اتَّقَى وَأْتُوا الْبُيُوتَ مِنْ أَبْوَابِهَا‏}‏‏.‏

sunnah.com