Pyridinic N-type doped at carbon has been known to have better electrocatalytic activity toward the oxygen reduction reaction (ORR) than the others. Herein, we proposed to prepare pyridinic N doped at carbon aerogels (CaA) derived from biomass, i.e., coir fiber (CF) and palm empty fruit bunches (PEFBs), by adjusting the pyrolysis temperature during carbonization of the biomass-based-cellulose aerogels. The cellulose aerogels were prepared by the ammonia-urea system as the cellulose solvent, in which ammonia also acted as a N source for doping and urea as the cellulose cross-linker. The as-prepared cellulose aerogels were directly pyrolyzed to produce N-doped CaA. It was found that the type of N doping is dominated by pyrrolic N at pyrolysis temperature of 600 °C, pyridinic N at 700 °C, and graphitic N at 800 °C. The pyridinic N exhibited better performance as an electrocatalyst for the ORR than pyrrolic N and graphitic N. The ORR using pyridinic N follows the four-electron pathway, which quantitatively implies a more electrochemically stable process. When used as a cathode for the Mg-air battery using a 3.5% NaCl electrolyte, the pyridinic N CaA exhibited excellent performance by giving a cell voltage of approximately 1.1 V and delivered a high discharge capacity of 411.64 mA h g-1 for CF and 492.64 mA h g-1 for PEFB corresponding to an energy density of 464.23 and 529.49 mW h g-1, respectively.