Taanis 19a. And so too a city where there is disease or falling pieces of buildings, that city fasts and blows the shofar, and all the surrounding cities fast, but do not blow the shofar.
Shulchan Aruch Orach Chaim 576:4: We fast because of falling pieces of buildings: if there were many incidents in the city of walls in good condition, not on the riverbank, falling, then it is a calamity and we fast and blow shofar because of it. Similarly, if there was an earthquake or a strong wind that knocked down buildings and killed people, we fast and blow shofar [so that it should not happen again].
תענית יט ע”א. וכן עיר שיש בה דבר או מפולת, אותה העיר מתענה ומתרעת וכל סביבותיה מתענות ולא מתריעות.
שו”ע או”ח תקע”ו ס”ד. וכן מתענין על המפולת שבעיר כיצד הרי שרבתה בעיר מפולת כותלים בריאים שאינן עומדין בצד הנהר ה״ז צרה ומתענין ומתריעין עליה וכן על הרעש ועל הרוחות שהם מפילים הבנין והורגים מתענים ומתריעין עליהם:
The Kaf Hachaim (Orach Chaim 576:26) quotes the Pri Haaretz who says that in Yerushalayim, if there was falling debris or an earthquake, we don’t fast so that it shouldn’t continue, because there is a tradition that falling debris never hurt anyone in Yerushalayim.
He then cites an example: in 5687 (1927) on the 11th of Tammuz, an earthquake struck Yerushalayim and its environs. Many walls fell down; other walls cracked. Miraculously, no one in Yerushalayim was killed; only in the surrounding villages were people killed. All observers marvelled at Hashem’s protection of the Jewish people, and even those who normally did not admit to anything supernatural believed in Hashem and testified that the hand of Hashem had done this.
Similarly, the Pe’as Hashulchan writes in a letter (printed at the beginning of his sefer) that in the famous earthquake of 1837, while hundreds died in Tiberias and Shechem, Yerushalayim had damage to some houses but “thank G-d, not a single person was harmed.”
[We could ask a question here: the Gemara in Berachos 3a states, “It is forbidden to enter a ruined building for three reasons: so as not to arouse suspicion that he is going there to commit a sin, due to falling debris and due to the demons.” The Gemara then explains why we need all these reasons: for each reason, there exists a case where only that reason applies. For example, if the ruins are new and located within a city, then they are unlikely to fall and there are no demons; the only reason would be suspicion. Now, if in Yerushalayim no one is ever harmed by falling debris, then why didn’t the Gemara give the case of a ruin in Yerushalayim?
One might have replied that this special Divine protection was not in effect yet in the Gemara’s time. However, Avos Derabbi Nosson 35:1 lists as one of the ten miracles in Yerushalayim that “falling debris never harmed anyone.” The commentary Kisei Rachamim explains that this means an earthquake.
Another question is that the Gemara says that if the tragedy happened in one city, the surrounding cities also fast. If so, why does the Kaf Hachaim say that Yerushalayim doesn’t fast? They should at least fast because of the surrounding cities that were harmed, as they were in 1927.
It must be that the Kaf Hachaim understood that the reason for fasting over a tragedy in another city is not to pray for the other city – they must pray for themselves – but rather to pray that the tragedy shouldn’t spread to this city.]