Sahih al Bukhari 5988
Good Manners and Form (Al-Adab)
حَدَّثَنَا خَالِدُ بْنُ مَخْلَدٍ، حَدَّثَنَا سُلَيْمَانُ، حَدَّثَنَا عَبْدُ اللَّهِ بْنُ دِينَارٍ، عَنْ أَبِي صَالِحٍ، عَنْ أَبِي هُرَيْرَةَ ـ رضى الله عنه ـ عَنِ النَّبِيِّ صلى الله عليه وسلم قَالَ " إِنَّ الرَّحِمَ سُجْنَةٌ مِنَ الرَّحْمَنِ، فَقَالَ اللَّهُ مَنْ وَصَلَكِ وَصَلْتُهُ، وَمَنْ قَطَعَكِ قَطَعْتُهُ ".
Narrated Abu Huraira:The Prophet (ﷺ) said, "The word 'Ar-Rahm (womb) derives its name from Ar-Rahman (i.e., one of the names of Allah) and Allah said: 'I will keep good relation with the one who will keep good relation with you, (womb i.e. Kith and Kin) and sever the relation with him who will sever the relation with you, (womb, i.e. Kith and Kin)
Text from the public-domain hadith-api dataset. Numbering follows that dataset and can differ by a few from some printed editions — check the wording, not only the number.