Background: Plant essential oils have long been regarded as repositories of antimicrobial agents. In recent years, they have emerged as potential alternatives or supplements to antimicrobial drugs. Although literature reviews and previous studies have indicated that cinnamon essential oil (CIEO) and its major component, cinnamaldehyde (CID), possess potent antibacterial activities, their antibacterial mechanisms, especially the in vivo antibacterial mechanisms, remain elusive. Methods: In this study, we utilized the in vivo assessment system of Caenorhabditis elegans (C. elegans) to investigate the effects and mechanisms of high dose (100mg/L) and low dose (10mg/L) CIEO and CID in inhibiting Pseudomonas aeruginosa (P. aeruginosa). In addition, we also examined the in vitro antibacterial abilities of CIEO and CID against other common pathogens including P. aeruginosa and 4 other strains. Results: Our research revealed that both high (100mg/L) and low doses (10mg/L) of CIEO and CID treatment significantly alleviated the reduction in locomotion behavior, lifespan, and accumulation of P. aeruginosa in C. elegans infected with the bacteria. During P. aeruginosa infection, the transcriptional expression of antimicrobial peptide-related genes (lys-1 and lys-8) in C. elegans was upregulated with low-dose CIEO and CID treatment, while this trend was suppressed at high doses. Further investigation suggested that the PMK-1 mediated p38 signaling pathway may be involved in the regulation of CIEO and CID during nematode defense against P. aeruginosa infection. Furthermore, in vitro experimental results also revealed that CIEO and CID exhibit good antibacterial effects, which may be associated with their antioxidant properties. Conclusion: Our results indicated that low-dose CIEO and CID treatment could activate the p38 signaling pathway in C. elegans, thereby regulating antimicrobial peptides, and achieving antimicrobial effects. Meanwhile, high doses of CIEO and CID might directly participate in the internal antimicrobial processes of C. elegans. Our study provides research basis for the antibacterial properties of CIEO and CID both in vivo and in vitro.