Space travel presents unlimited opportunities for exploration and discovery, but requires better understanding of the biological consequences of long-term exposure to spaceflight. Immune function in particular is relevant for space travel. Human immune responses are weakened in space, with increased vulnerability to opportunistic infections and immune-related conditions. In addition, microorganisms can become more virulent in space, causing further challenges to health. To understand these issues better and to contribute to design of effective countermeasures, we used the Drosophila model of innate immunity to study immune responses in both hypergravity and spaceflight. Focusing on infections mediated through the conserved Toll and Imd signaling pathways, we found that hypergravity improves resistance to Toll-mediated fungal infections except in a known gravitaxis mutant of the yuri gagarin gene. These results led to the first spaceflight project on Drosophila immunity, in which flies that developed to adulthood in microgravity were assessed for immune responses by transcription profiling on return to Earth. Spaceflight alone altered transcription, producing activation of the heat shock stress system. Space flies subsequently infected by fungus failed to activate the Toll pathway. In contrast, bacterial infection produced normal activation of the Imd pathway. We speculate on possible linkage between functional Toll signaling and the heat shock chaperone system. Our major findings are that hypergravity and spaceflight have opposing effects, and that spaceflight produces stress-related transcriptional responses and results in a specific inability to mount a Toll-mediated infection response.