Sahih Muslim, Book 39, Hadith 173 (Muslim 5763)

Safiyya reported from some of the wives of Allah's Apostle (ﷺ) Allah's Apostle (ﷺ) having said:

He who visits a diviner ('Arraf) and asks him about anything, his prayers extending to forty nights will not be accepted.