Large-scale application of p-nitrophenol (PNP) will inevitably cause environmental issue, while adsorption treatment using carbon-based adsorbents is an effective way to remove PNP from water. Herein we report a recyclable MgO-templating one step strategy to synthesize N/O co-doped hierarchical porous carbons derived from inexpensive petroleum pitch (PP) with low-dose melamine. The MgO-template precursor could be removed and recycled by acetic acid leaching, almost without template consumption and saline wastewater generation during the whole synthetic process, and the porous carbons prepared from the recycled magnesium acetate exhibited consistent hierarchical pore structures. The obtained porous carbons possess tunable specific surface area with the varying ratio of MgO template to PP. The sample of MPHPC-1.25 with high specific surface area of 1010.73 m2/g and volume of 1.68 cm3/g exhibits remarkable PNP adsorption capacity of 626.02 mg/g in batch and of 427.15 mg/g in dynamic fixed-bed adsorption test. In addition, the MPHPC-1.25 shows outstanding tolerance for PNP adsorption under various ionic backgrounds and excellent adsorption stability and reusability in continuous adsorption-regeneration cycles, suggesting its high potential in practical application. Furthermore, the enhanced PNP adsorption mechanism based on hierarchical pore structure and strong electrostatic interaction between PNP and N, O species dominated by pyridinic-N and carboxyl groups was elucidated by a combination of material characterization, adsorption thermodynamic-kinetic evaluation and DFT calculations.