Here we definitively demonstrate a functional role of the UPR in defense against a pathogen in vivo. Loss of xbp-1 leads to animals nearly 6 fold more susceptible to PFT whereas loss of atf-6 leads to animals nearly 3 fold more susceptible.