Anas bin Malik reported,

The Prophet ﷺ said, "When a servant is placed in his grave and his companions turn away from him, he hears the sound of their sandals as they leave. Then two angels come to him, sit him up, and ask, 'What did you used to say about this man, Muhammad ﷺ?'The believer replies, 'I testify that he is the servant of Allah and His Messenger.'It is then said to him, 'Look at your place in the Fire. Allah has replaced it for you with a place in Paradise.'"The Prophet ﷺ said, "He sees them both.As for the disbeliever or the hypocrite, he says, 'I do not know. I used to say whatever the people said.'It is said to him, 'You did not know and you did not follow those who knew.' Then he is struck with an iron hammer between his ears, and he lets out a scream heard by everything near him except humans and jinn."

Bukhari 1338

Sahih

حدثنا عياش حدثنا عبد الأعلى حدثنا سعيد قال وقال لي خليفة حدثنا يزيد بن زريع حدثنا سعيد عن قتادة

عن أنس رضي الله عنه

عن النبي ﷺ قال العبد إذا وضع في قبره وتولي وذهب أصحابه حتى إنه ليسمع قرع نعالهم أتاه ملكان فأقعداه فيقولان له ما كنت تقول في هذا الرجل محمد ﷺ فيقول أشهد أنه عبد الله ورسوله فيقال انظر إلى مقعدك من النار أبدلك الله به مقعدا من الجنة قال النبي ﷺ فيراهما جميعا وأما الكافر أو المنافق فيقول لا أدري كنت أقول ما يقول الناس فيقال لا دريت ولا تليت ثم يضرب بمطرقة من حديد ضربة بين أذنيه فيصيح صيحة يسمعها من يليه إلا الثقلين

البخاري 1338صحيح
Contents
Reference
Commentary
Ayat
Collection
Sahih Bukhari
Book
Funerals
Chapter
Deceased hears the sound of sandals
Numbering
Darussalam 1338
Bukhari 1338