g-C3N4 is a promising material for the application in the area of photoelectrochemical cathodic protection. However, it suffers from limited light absorption and lower charge separation efficiency. In this work, a N defects and C deposition co-modified g-C3N4, C–g-C3Nx, was prepared by NaOH-assisted sintering and ethanol-assisted hydrothermal treatment. The presence of N defects and C deposition was verified by the XRD, SEM and XPS tests. The N defects changed the band structure of g-C3N4 by lowering down the conduction band position, therefore widening the light absorption range of g-C3N4. In addition, the N defects and C deposition co-modification promotes the charge transfer process of g-C3N4, leading to increased separation efficiency of the photogenerated charge carriers. Therefore, C–g-C3Nx shows enhanced photoelectrochemical cathodic protection performance for the coupled 316L stainless steel. It can provide a photoinduced potential drop of 120 mV and a photoinduced current density of 9.1 μA cm−2, which is three times that of pristine g-C3N4.