Caution: Translations of Quran and Ḥadīth may lead to possible misapplications and misinterpretations. This site is intended for students of sacred knowledge that are proficient in comprehending classical Arabic and have a strong foundation in Islamic sciences. Also note that religious injunctions rely on several aspects beyond what one may glean through reading individual aḥādīth.
quran:4:97

Indeed, those whom the angels take ˹in death˺ while wronging themselves - ˹the angels˺ will say, "In what ˹condition˺ were you?" They will say, "We were oppressed in the land." The angels will say, "Was not the earth of Allah spacious ˹enough˺ for you to emigrate therein?" For those, their refuge is Hell - and evil it is as a destination.  

The following was revealed regarding a group of people who submitted to Islam but did not emigrate and were then slain in the battle of Badr alongside the disbelievers: And those whom the angels take ˹in death˺, while they are wronging their souls, having remained among the disbelievers and neglected to emigrate, the angels will say, to them in rebuke: ‘What was your predicament?’, in other words, ‘in what circumstances were you with regard to your religion’. They will say, giving excuses, ‘We were oppressed, unable to establish religion, in the land’, the land of Mecca. The angels will say, to them in rebuke: ‘But was not God’s earth spacious that you might have emigrated therein?’, from the land of unbelief to another land, as others did? God, exalted be He, says: as for such, their abode shall be Hell — an evil journey’s end, it is!
القرآن:٤:٩٧

إِنَّ الَّذِينَ تَوَفَّاهُمُ الْمَلَائِكَةُ ظَالِمِي أَنْفُسِهِمْ قَالُوا فِيمَ كُنْتُمْ ۖ قَالُوا كُنَّا مُسْتَضْعَفِينَ فِي الْأَرْضِ ۚ قَالُوا أَلَمْ تَكُنْ أَرْضُ اللَّهِ وَاسِعَةً فَتُهَاجِرُوا فِيهَا ۚ فَأُولَٰئِكَ مَأْوَاهُمْ جَهَنَّمُ ۖ وَسَاءَتْ مَصِيرًا  

{إن الذين توفاهم الملائكة ظالمي أنفسهم} بالمقام مع الكفار وترك الهجرة {قالوا} لهم موبخين {فيم كنتم} أي في شيء كنتم في أمر دينكم {قالوا} معتذرين {كنا مستضعَفين} عاجزين عن إقامة الدين {في الأرض} أرض مكة {قالوا} لهم توبيخا {ألم تكن أرض الله واسعة فتهاجروا فيها} من أرض الكفر إلى بلد آخر كما فعل غيركم، قال الله تعالى {فأولئك مأواهم جهنم وساءت مصيرا} هي.

See similar narrations below:

Collected by Bayhaqī
bayhaqi:17749Abū ʿAbdullāh al-Ḥāfiẓ > Abū Bakr Muḥammad b. ʿAbdullāh al-Shāfiʿī > Muḥammad b. Maslamah al-Wāsiṭī > ʿAbdullāh b. Yazīd al-Muqriʾ > Ḥaywah And a man > Muḥammad b. ʿAbd al-Raḥman b. Nawfal al-Asadī > Quṭiʿ > Ahl al-Madīnah Baʿth Liyanhab Fīh Falaqīt ʿIkrimah a freed slave of Ibn ʿAbbās Fanahānī Ashad al-Nahy Thum > Ibn ʿAbbās

[Machine] Some of the Muslims used to be with the polytheists and increase the harm against the Messenger of Allah, ﷺ . They would throw arrows and hit one of them, killing him or causing him injury. So Allah, exalted be He, revealed this verse about them: "Indeed, those whom the angels take [in death] while wronging themselves, [the angels] will say, 'In what [condition] were you?' They will say, 'We were oppressed in the land.' The angels will say, 'Was not the earth of Allah spacious [enough] for you to emigrate therein?' For those, their refuge is Hell - and evil it is as a destination." [Quran 4:97]  

البيهقي:١٧٧٤٩أَخْبَرَنَا أَبُو عَبْدِ اللهِ الْحَافِظُ ثنا أَبُو بَكْرٍ مُحَمَّدُ بْنُ عَبْدِ اللهِ الشَّافِعِيُّ ثنا مُحَمَّدُ بْنُ مَسْلَمَةَ الْوَاسِطِيُّ ثنا عَبْدُ اللهِ بْنُ يَزِيدَ الْمُقْرِئُ ثنا حَيْوَةُ وَرَجُلٌ قَالَا ثنا مُحَمَّدُ بْنُ عَبْدِ الرَّحْمَنِ بْنِ نَوْفَلٍ الْأَسَدِيُّ قَالَ قُطِعَ عَلَى أَهْلِ الْمَدِينَةِ بَعْثٌ لِيَنْهَبَ فِيهِ فَلَقِيتُ عِكْرِمَةَ مَوْلَى ابْنِ عَبَّاسٍ فَنَهَانِي أَشَدَّ النَّهْيِ ثُمَّ قَالَ أَخْبَرَنِي ابْنُ عَبَّاسٍ ؓ أَنَّ

نَاسًا مِنَ الْمُسْلِمِينَ كَانُوا مَعَ الْمُشْرِكِينَ يُكَثِّرُونَ سَوَادَ الْمُشْرِكِينَ عَلَى رَسُولِ اللهِ ﷺ فَيَأْتِي السَّهْمُ يُرْمَى بِهِ فَيُصِيبُ أَحَدَهُمْ فَيَقْتُلُهُ أَوْ يُضْرَبُ فَيُقْتَلُ فَأَنْزَلَ اللهُ تَعَالَى ذِكْرَهُ فِيهِمْ {إِنَّ الَّذِينَ تَوَفَّاهُمُ الْمَلَائِكَةُ ظَالِمِي أَنْفُسِهِمْ قَالُوا فِيمَ كُنْتُمْ قَالُوا كُنَّا مُسْتَضْعَفِينَ فِي الْأَرْضِ قَالُوا أَلَمْ تَكُنْ أَرْضُ اللهِ وَاسِعَةً فَتُهَاجِرُوا فِيهَا فَأُولَئِكَ مَأْوَاهُمْ جَهَنَّمُ وَسَاءَتْ مَصِيرًا} [النساء 97]  

رَوَاهُ الْبُخَارِيُّ فِي الصَّحِيحِ عَنْ عَبْدِ اللهِ بْنِ يَزِيدَ الْمُقْرِئِ