Oxygen (O2) is a double-edged sword to cells, for while it is vital for energy production in all aerobic animals and insufficient O2 (hypoxia) can lead to cell death, the reoxygenation of hypoxic tissues may trigger the generation of reactive oxygen species (ROS) that can destroy any biological molecule. Indeed, both hypoxia and hypoxia-reoxygenation (H/R) stress are harmful, and may play a critical role in the pathophysiology of many human diseases, such as myocardial ischemia and stroke. Therefore, understanding how animals adapt to hypoxia and H/R stress is critical for developing better treatments for these diseases. Previous studies showed that the neuroglobin GLB-5(Haw) is essential for the fast recovery of the nematode Caenorhabditis elegans (C. elegans) from H/R stress. Here, we characterize the changes in neuronal gene expression during the adaptation of worms to hypoxia and recovery from H/R stress. Our analysis shows that innate immunity genes are differentially expressed during both adaptation to hypoxia and recovery from H/R stress. Moreover, we reveal that the prolyl hydroxylase EGL-9, a known regulator of both adaptation to hypoxia and the innate immune response, inhibits the fast recovery from H/R stress through its activity in the O2-sensing neurons AQR, PQR, and URX. Finally, we show that GLB-5(Haw) acts in AQR, PQR, and URX to increase the tolerance of worms to Pseudomonas aeruginosa pathogenesis. Together, our studies suggest that innate immunity and recovery from H/R stress are regulated by overlapping signaling pathways.