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:16:112

And Allah presents an example: a city which was safe and secure, its provision coming to it in abundance from every location, but it denied the favors of Allah. So Allah made it taste the envelopment of hunger and fear for what they had been doing.  

And God strikes a similitude (mathalan is substituted by ˹the following, qaryatan˺) a town, Mecca — meaning its inhabitants — secure, from any raids, never becoming agitated, and peaceful, without anyone ever needing to emigrate from it, on account of anxiety or fear, its provision coming to it plenteously, abundantly, from every place. But it rejected God’s graces, by denying the Prophet (s), so God made it taste the garb of hunger, and so they suffered seven years of drought, and fear, as a result of the raiding parties of the Prophet (s), ˹all˺ because of what they used to do.
القرآن:١٦:١١٢

وَضَرَبَ اللَّهُ مَثَلًا قَرْيَةً كَانَتْ آمِنَةً مُطْمَئِنَّةً يَأْتِيهَا رِزْقُهَا رَغَدًا مِنْ كُلِّ مَكَانٍ فَكَفَرَتْ بِأَنْعُمِ اللَّهِ فَأَذَاقَهَا اللَّهُ لِبَاسَ الْجُوعِ وَالْخَوْفِ بِمَا كَانُوا يَصْنَعُونَ  

{وضرب الله مثلاً} ويبدل منه {قرية} هي مكة والمراد أهلها {كانت آمنة} من الغارات لا تهاج {مطمئنة} لا يحتاج إلى الانتقال عنها لضيق أو خوف {يأتيها رزقها رغدا} واسعا {من كل مكان فكفرت بأنعم الله} بتكذيب النبي ﷺ {فأذاقها الله لباس الجوع} فقحطوا سبع سنين {والخوف} بسرايا النبي ﷺ {بما كانوا يصنعون}.