A metal-free polymeric material, graphitic carbon nitride (g-C3N4) nanorods, has been designed for photoelectrochemical detection of copper(II) ions. The g-C3N4 nanorods have been fabricated by means of hydrothermally treated bulk g-C3N4 using NH4Cl. The crystalline structure and the core chemical skeleton of g-C3N4 do not alter after hydrothermal treatment using NH4Cl. The morphology of g-C3N4 is changed from nanosheet to nanorod after hydrothermal treatment. The g-C3N4 nanorods possess significant advantages of enhanced light absorption and charge separation, thereby resulting in an improvement in the photocurrent intensity. A photoelectrochemical sensor has been developed based on the g-C3N4 nanorods. The results show that the designed sensor has high sensitivity as well as good selectivity for Cu2+ detection. The photoelectrochemical sensor provides a promising method for monitoring metal ions and opens a new avenue for the applications of g-C3N4 nanorods.