Anas bin Malik reported,

The Messenger of Allah ﷺ entered a palm grove belonging to Banu Najjar and heard a sound, which startled him.He asked, "Who are the people buried in these graves?"They said, "Messenger of Allah, they are people who died in the days of ignorance."He said, "Seek refuge with Allah from the punishment of the Fire and from the trial of Dajjal."They asked, "Why is that, Messenger of Allah?"He said, "When a believer is laid in his grave, an angel comes to him and asks, 'What did you worship?' If Allah has guided him, he answers, 'I worshipped Allah.' Then he is asked, 'What did you say about this man?' He replies, 'He is Abdullah and His Messenger.' He is asked about nothing else besides that. Then he is taken to a house that had been prepared for him in the Fire, and he is told, 'This was your house in the Fire, but Allah protected you and had mercy on you, and exchanged it for a house in Paradise.' He says, 'Let me go and give my family the good news.' He is told, 'Stay where you are.'But when the disbeliever is laid in his grave, an angel comes to him and rebukes him harshly, asking, 'What did you worship?' He says, 'I do not know.' He is told, 'You neither knew nor followed.' Then he is asked, 'What did you say about this man?' He says, 'I only said what people were saying.' So the angel strikes him between the ears with an iron hammer, and he lets out a cry heard by all creation except mankind and jinn."In another wording he said, "When a servant is laid in his grave and his companions turn away from him, he hears the sound of their sandals. Two angels come to him and say to him..." and he mentioned something close to the first report. In it he said, "As for the disbeliever and the hypocrite, the two angels say to him..." He added the mention of the hypocrite, and he said, "It is heard by those near him, other than mankind and jinn."

Abu Dawud 4752

Sahih

حدثنا محمد بن سليمان حدثنا عبد الوهاب بمثل هذا الإسناد نحوه قال إن العبد إذا وضع في قبره وتولى عنه أصحابه إنه ليسمع قرع نعالهم فيأتيه ملكان فيقولان له فذكر قريبا من حديث الأول قال فيه وأما الكافر والمنافق فيقولان له زاد المنافق وقال يسمعها من وليه غير الثقلين

أبو داود 4752صحيح
Contents
Reference
Commentary
Ayat
Collection
Sunan Abu Dawud
Book
Sunnah
Chapter
Questioning in the grave and punishment of the grave
Numbering
Darussalam 4752
Abu Dawud 4752