Phosphorus and silicon co-doped graphitic carbon nitride (PSiCN) was synthesized by inducing the polycondensation reaction of melamine, diammonium hydrogen phosphate, and silicic acid. The structure and thermal properties of PSiCN were characterized. With the incorporation of 2 wt% of PSiCN and 8 wt% of ammonium polyphosphate (APP), EP/2PSiCN-8APP composite exhibited a limiting oxygen index value of 29.0% and passed a UL-94V-0 rating, which reached the refractory level. The thermogravimetric analysis confirmed that the addition of PSiCN and APP improved the thermal stability of the composites. The cone calorimetry test (CCT) revealed that the peak of heat release rate, total heat release, the peak of smoke production rate and total smoke production of EP/2PSiCN-8APP composite was reduced by 71.1%, 53.5%, 65.4%, and 53.5%, respectively, compared with pure EP. Furthermore, the residues after CCT were evaluated by scanning electron microscopy, laser Raman spectroscopy and Fourier transform infrared spectroscopy, and the flame retardant mechanism of EP/2PSiCN-8APP composite was proposed. Finally, the parallel arrangement of the aromatic ring and the surface of the PSiCN and the synergistic effect of the P/N/Si multi-element resulted in EP/2PSiCN-8APP with excellent mechanical properties.