Sunan Abi Dawud, Hadith 5004

Jabir reported the Messenger of Allah (May peace be upon him) as saying : When one of you sees a vision which he dislikes, he must spit on his left (three times), seek refuge in Allah from the devil three times, and turn from the side on which he was lying.

حَدَّثَنَا يَزِيدُ بْنُ خَالِدٍ الْهَمْدَانِيُّ، وَقُتَيْبَةُ بْنُ سَعِيدٍ الثَّقَفِيُّ، قَالاَ أَخْبَرَنَا اللَّيْثُ، عَنْ أَبِي الزُّبَيْرِ، عَنْ جَابِرٍ، عَنْ رَسُولِ اللَّهِ صلى الله عليه وسلم أَنَّهُ قَالَ ‏ "‏ إِذَا رَأَى أَحَدُكُمُ الرُّؤْيَا يَكْرَهُهَا فَلْيَبْصُقْ عَنْ يَسَارِهِ وَلْيَتَعَوَّذْ بِاللَّهِ مِنَ الشَّيْطَانِ ثَلاَثًا وَيَتَحَوَّلْ عَنْ جَنْبِهِ الَّذِي كَانَ عَلَيْهِ ‏" ‏ ‏.‏

sunnah.com

also referenced under: Hadith 5022 (DarusSalam)