The Messenger of Allah ﷺ said, "When a snake appears in your dwelling, say to it, 'We ask you by the covenant of Nuh and the covenant of Sulayman bin Dawud not to harm us.' If it returns, then kill it."
حدثنا هناد حدثنا ابن أبي زائدة حدثنا ابن أبي ليلى عن ثابت البناني عن عبد الرحمن بن أبي ليلى قال قال
رسول الله ﷺ إذا ظهرت الحية في المسكن فقولوا لها إنا نسألك بعهد نوح وبعهد سليمان بن داود أن لا تؤذينا فإن عادت فاقتلوها
No references are available.
[Its chain of transmission is daif] Abu Dawud also narrated it in Kitab al-Adab, Bab fi qatl al-hayyat, no. 5260, through Muhammad bin Abdul-Rahman bin Abu Layla, with the same wording, and it is daif.