BackgroundThe diagnosis ofPneumocystispneumonia (PCP) remains challenging in certain specific clinical situations. Metagenomic next-generation sequencing (mNGS), as a novel diagnostic method, may help in the diagnosis of PCP.Case presentationA 6-month-old male child developed acute pneumonia and sepsis. This child had previously suffered fromEscherichia colisepticemia and was cured. However, the fever and dyspnea relapsed. Blood tests revealed a low lymphocyte count (0.69 × 109/L) and acute inflammatory markers such as high-level procalcitonin (8.0 ng/ml) and C-reactive protein (19 mg/dl). Chest imaging showed inflammation and decreased translucency in both lungs but no thymus shadow. Various serology tests, the 1,3-beta-D-glucan test, culture, as well as sputum smear failed to detect any pathogens. mNGS with blood helped identify 133 specific nucleic acid sequences ofPneumocystis jirovecii, suggesting an infection with this pathogen. After treatment with trimethoprim-sulfamethoxazole for 5 days, the patient's condition improved, but the child still needed ventilator support. Unfortunately, the child died soon after because of respiratory failure after his parents decided to abandon treatment. The family declined an autopsy on the child, and therefore, an anatomical diagnosis could not be obtained. Whole-exome sequencing suggested X-linked immunodeficiency. A hemizygous mutation of c.865c > t (p.r289*) was detected in theIL2RGgene, which was inherited from the mother (heterozygous state).ConclusionThis case report highlights the value of mNGS in diagnosing PCP when conventional diagnostic methods fail to identify the agent. Early onset of recurrent infectious diseases may indicate the presence of an immunodeficiency disease, for which timely genetic analysis and diagnosis are crucial.