Ammonia stress and nitrite stress can induce immune depression and oxidative stress inLitopenaeus vannami(L. vannamei). Earlier reports showed thatL. vannameiimmunity, resistance to ammonia stress, and resistance to nitrite stress improved after Tian–Dong–Tang–Gan Powder (TDTGP) treatment, but the mechanism is not clear. In this study, three thousandL. vannameiwere fed different doses of TDTGP for 35 days and then subjected to ammonia and nitrite stress treatments for 72 h. Transcriptome and 16-Seq ribosomal RNA gene sequencing (16S rRNA-seq) were used to analyze hepatopancreas gene expression and changes in gut microbiota abundance in each group. The results showed that after TDTGP treatment, hepatopancreas mRNA expression levels of immunity- and antioxidant-related genes were increased, the abundance ofVibrionaceaein the gut microbiota was decreased, and the abundance ofRhodobacteraceaeandFlavobacteriaceaewas increased. In addition, after TDTGP treatment, the effects of ammonia and nitrite stress on the mRNA expression of Pu, cat-4, PPAF2, HO, Hsp90b1, etc. were reduced and the disruption of the gut microbiota was alleviated. In short, TDTGP can regulate the immunity and antioxidant ofL. vannameiby increasing the expression levels of immunity- and antioxidant-related genes and regulating the abundance ofRhodobacteraceaeandFlavobacteriaceaein the gut microbiota.