Autophagy is a process that promotes the lysosomal degradation of cytoplasmic proteins and is highly conserved in eukaryotic organisms. Autophagy maintains homeostasis in organisms and regulates multiple developmental processes, and autophagy disruption is related to human diseases. However, the functional roles of autophagy in mediating innate immune responses are largely unknown. In this study, we sought to understand how Atg2, an autophagy-related gene, functions in the innate immunity of Drosophila melanogaster. The results showed that a large number of melanotic nodules were produced upon inhibition of Atg2. In addition, inhibiting Atg2 suppressed the phagocytosis of latex beads, Staphylococcus aureus and Escherichia coli; the proportion of Nimrod C1 (one of the phagocytosis receptors)-positive hemocytes also decreased. Moreover, inhibiting Atg2 altered actin cytoskeleton patterns, showing longer filopodia but with decreased numbers of filopodia. The expression of AMP-encoding genes was altered by inhibiting Atg2. Drosomycin was upregulated, and the transcript levels of Attacin-A, Diptericin and Metchnikowin were decreased. Finally, the above alterations caused by the inhibition of Atg2 prevented flies from resisting invading pathogens, showing that flies with low expression of Atg2 were highly susceptible to Staphylococcus aureus and Erwinia carotovora carotovora 15 infections. In conclusion, Atg2 regulated both cellular and humoral innate immunity in Drosophila. We have identified Atg2 as a crucial regulator in mediating the homeostasis of immunity, which further established the interactions between autophagy and innate immunity.