A simple technique to prepare g-C3N4/Fe3O4 nanocomposites by electrostatic interaction has been demonstrated by carboxyl g-C3N4 nanosheets and Fe3O4 nanoparticles which contain amino groups. The nanocomposites were characterized by transmission electron microscopy and Fourier transform infrared spectroscopy. The emission of the g-C3N4/Fe3O4 nanocomposites was quenching when Cu2+ was detected and recovering after adding the EDTA solution. At the optimum conditions, the fluorescence intensity is proportional to the concentration of Cu2+ in the range of 0–8 × 10−5 mol/L. The linear regression equation is Y = − 16.87X + 0.6209, and the correlation coefficient is 0.998. The sensing system has good reproducibility when it is used to detect Cu2+. This sensor would be a common platform for detecting Cu2+ in the aqueous system.