A man who had been born in Madinah died there, and the Messenger of Allah ﷺ performed the funeral prayer over him. He then said, "If only he had died somewhere other than his birthplace."The people asked, "Why is that, Messenger of Allah?"He replied, "When a man dies somewhere other than his birthplace, a measure is taken for him in Paradise from his birthplace to the place where his traces ended."
أخبرنا يونس بن عبد الأعلى قال أنبأنا ابن وهب قال أخبرني حيي بن عبد الله عن أبي عبد الرحمن الحبلي
مات رجل بالمدينة ممن ولد بها فصلى عليه رسول الله ﷺ ثم قال يا ليته مات بغير مولده قالوا ولم ذاك يا رسول الله قال إن الرجل إذا مات بغير مولده قيس له من مولده إلى منقطع أثره في الجنة
Sourcing, [Its chain of transmission is hasan] Ibn Majah narrated it in the Book of Funerals, chapter on what has been mentioned about one who dies as a stranger, no. 1614, from the hadith of Abdullah bin Wahb, through him. It is also in Al-Kubra, no. 1958, and Ibn Hibban graded it sahih in Al-Mawarid, no. 729.