IL-23, produced by dendritic cells (DCs) and macrophages, plays a critical role in innate immunity against bacterial infection. Our previous studies show that morphine disrupts the IL-23/IL-17 mediated pulmonary mucosal host defense and increases susceptibility to Streptococcus pneumoniae lung infection. To determine the mechanism by which morphine modulates IL-23 production, mouse bone marrow-derived dendritic cells (BMDCs) and macrophages (BMDMs) were treated with morphine, and infected with S. pneumoniae or stimulated with Toll-like receptor (TLR) and Nod2 ligands. We found that a significant increase in IL-23 protein production was observed in S. pneumoniae, TLR2 ligand lipoteichoic acid (LTA), and TLR4 ligand pneumolysin (PLY) stimulated BMDCs and BMDMs. Interestingly, although Nod2 ligand muramyldipeptide (MDP) alone had no effect on IL-23 production, it potentiated LTA induced IL-23 production to the same level as that observed following S. pneumoniae infection, suggesting that S. pneumoniae induced IL-23 production in DCs involves activation of both TLR2 and Nod2 signaling mechanisms. Furthermore, pretreatment of DCs with MyD88 (myeloid differentiation primary response gene 88) and IL-1 receptor-associated kinase (IRAK) 1/4 inhibitors, or TLR2 antibody diminished the S. pneumoniae induced IL-23 and abolished the inhibitory effects of morphine, indicating that S. pneumoniae induced IL-23 production depends on activation of the TLR2-MyD88-IRAK1/4 signaling pathway. Moreover, morphine decreased S. pneumoniae induced phosphorylation of interferon regulatory factor 3 (IRF3) and activating transcription factor 2 in DCs. Taken together, our study shows that morphine impairs S. pneumoniae induced IL-23 production through MyD88-IRAK1/4-dependent TLR2 and Nod2 signaling in DCs.