The transition energies and formation energies of N, C, F, Cl, and S as substitutional dopants in Ag3PO4 are studied using first-principles calculations based on the hybrid Hartree-Fock density functional, which correctly reproduces the band gap and thus provides the accurate defect states. Our results show that NO and CO act as deep acceptors, FO, ClO, and SP act as shallow donors. NO and CO have high formation energies under O-poor condition therefore they are not suitable for p-type doping Ag3PO4. Though FO, ClO, and SP have shallow transition energies, they have high formation energies, thus FO, ClO, and SP may be compensated by the intrinsic defects (such as Ag vacancy) and they are not possible lead to n-type conductivity in Ag3PO4.