If you get news of the outbreak of a plague in a land, do not enter it, and if it breaks out in a land in which you are, do not leave it
Authentic hadithعن أسامة بن زيد رضي الله عنهما مرفوعاً: «إذا سمعتم الطاعونَ بأرض فلا تدخلوها وإذا وقع بأرض وأنتم فيها فلا تخرجوا منها».
Usāmah ibn Zayd (may Allah be pleased with him) reported that the Prophet (may Allah's peace and blessings be upon him) said: "If you get news of the outbreak of a plague in a land, do not enter it, and if it breaks out in a land in which you are, do not leave it.”
Explanation
If a plague or epidemic breaks out in a part of the world that the person is not in, then it is not permissible for him to enter that plagued land so as to protect his health and the health of others. If the plague breaks out in a land that he is already in, then it is not permissible for him to leave that land, and he should be patient and accept whatever Allah decrees for him to receive the due reward for that.
Source · Narrated by Bukhari & Muslim
From the Hadith Encyclopedia (hadeethenc.com).