The hydrogen energy and CO2 reduction in-situ recombination has drawn increasing attention. Microbial electrosynthesis (MES) integrated with photocatalytic materials is a novel technology for CO2 utilization. Here, MES with the photocathode CoP-Fe2O3/g-C3N4 was constructed using Ralstonia eutropha as biocatalyst to generate polyhydroxybutyrate (PHB). The integration of CoP and Fe2O3/g-C3N4 facilitated electron–hole pair separation and electron transfer, which enhanced hydrogen evolution reaction and provided additional reducing power for CO2 conversion. Simultaneously, the concentration of reactive oxygen species was also considerably reduced, increasing the production of PHB. In particular, 87.54 mg/L of PHB was obtained in CoP-Fe2O3/g-C3N4 at − 1.05 V, which is about three times higher than that in carbon felt. At − 0.9 V, PHB concentration further increased to 142.20 mg/L. This study provides a new approach for converting CO2 into multicarbon compounds in situ electrolysis of water under visible light.