Caution: Translations of Quran and Ḥadīth may lead to possible misapplications and misinterpretations. This site is intended for students of sacred knowledge that are proficient in comprehending classical Arabic and have a strong foundation in Islamic sciences. Also note that religious injunctions rely on several aspects beyond what one may glean through reading individual aḥādīth.
suyuti:2183a

That the Messenger of Allah ﷺ said: "When a snake appears in your dwellings then say to it: We ask you - by covenant of Nuh, and by the covenant of Sulaiman bin Dawud - that you do not harm us.' If it returns, then kill it." (Using translation from Tirmidhī 1485)   

السيوطي:٢١٨٣a

"إذا ظَهَرت الحيَّةُ في المسكَنِ فقولوا لها: إنَّا نسْألكِ بْعهدِ نُوحٍ وبعهْدِ سُليمانَ بنِ داودَ ألا تُؤذِينا فإنْ عَادتْ فاقْتُلوها".  

[ت] الترمذي حسن غريب، [طب] الطبرانى في الكبير عن أبي لْيَلى

See similar narrations below:

Collected by Tirmidhī
tirmidhi:1485Hannād > Ibn Abū Zāʾidah > Ibn Abū Laylá > Thābit al-Bunānī > ʿAbd al-Raḥman b. Abū Laylá > Abū Laylá

That the Messenger of Allah ﷺ said: "When a snake appears in your dwellings then say to it: We ask you - by covenant of Nuh, and by the covenant of Sulaiman bin Dawud - that you do not harm us.' If it returns, then kill it."  

الترمذي:١٤٨٥حَدَّثَنَا هَنَّادٌ حَدَّثَنَا ابْنُ أَبِي زَائِدَةَ حَدَّثَنَا ابْنُ أَبِي لَيْلَى عَنْ ثَابِتٍ الْبُنَانِيِّ عَنْ عَبْدِ الرَّحْمَنِ بْنِ أَبِي لَيْلَى قَالَ قَالَ أَبُو لَيْلَى

قَالَ رَسُولُ اللَّهِ ﷺ إِذَا ظَهَرَتِ الْحَيَّةُ فِي الْمَسْكَنِ فَقُولُوا لَهَا إِنَّا نَسْأَلُكِ بِعَهْدِ نُوحٍ وَبِعَهْدِ سُلَيْمَانَ بْنِ دَاوُدَ أَنْ لاَ تُؤْذِينَا فَإِنْ عَادَتْ فَاقْتُلُوهَا  

قَالَ أَبُو عِيسَى هَذَا حَدِيثٌ حَسَنٌ غَرِيبٌ لاَ نَعْرِفُهُ مِنْ حَدِيثِ ثَابِتٍ الْبُنَانِيِّ إِلاَّ مِنْ هَذَا الْوَجْهِ مِنْ حَدِيثِ ابْنِ أَبِي لَيْلَى