In view of the harmfulness of chloramphenicol to the human body, the design of high-performance and selective photoelectrochemical aptasensor is extremely urgent for realizing the residual chloramphenicol determination. Herein, a self-powered photoelectrochemical chloramphenicol aptasensor based on AgBr/BiOBr composites has been fabricated, and AgBr/BiOBr heterojunction were prepared via in situ ionic liquid dihexadecyldimethylammonium bromide assisted precipitation method. Given the introduction of visible-light-response AgBr, the absorption edge of AgBr/BiOBr heterojunction exhibited slightly redshift, promoting large amounts of carriers' generation. Moreover, the formation of AgBr/BiOBr heterojunction can be beneficial to separating and migrating the photoinduced carriers. Both of these points endow AgBr/BiOBr heterojunction excellent photoelectrochemical performance. Therefore, a chloramphenicol-aptamer as a specific recognition element was combined with AgBr/BiOBr/indium tin oxide for designing a self-powered photoelectrochemical chloramphenicol aptasensor. This developed platform achieved chloramphenicol detection with the prominent analytical capability, such as wide linear detection range (0.001–300 nM), low detection limit (0.34 pM), high anti-interference, and feasibility for detecting real milk and river water samples. In addition, the low-cost, easy-operation, and high-sensitivity photoelectrochemical aptasensor using AgBr-based photoelectrochemical active materials is expected to be beneficial to monitoring environmental pollutants.