Halachah · Shulchan Aruch

Shulchan Arukh, Orach Chayim 578/שולחן ערוך·אורח חיים תקע״ח

אשכל יחיד יתענה ויתפלל על צרתו. ובו סעיף אחד:
כשם שהצבור מתענים ומתפללים על צרתם כך כל יחיד מתענה ומתפלל על צרתו כיצד היה לו חולה או תועה במדבר או חבוש בבי' האסורי' יש לו להתענו' ולבקש רחמים בתעניתו ולא יתענה בשבת ובמועד וחנוכה ופורים וראש חודש:
1"That every individual should fast and pray for their distress. In one section:Just as the community fasts and prays for their troubles, so too, each individual should fast and pray for their own distress. For example, if one is sick, lost in the wilderness, or imprisoned in a prohibited place, they should engage in fasting and seek mercy during their fast. However, one should not fast on Shabbat, Festivals, Chanukah, Purim, and Rosh Chodesh.