In order to qualitatively and quantitatively analyze the effects of N source impurity species and concentrations on the properties of epitaxial GaN layers, we intentionally introduced the oxygen‐containing species CO and CO2 into GaN layers during growth. Subsequently, we determined the impurities or elements that had a strong effect on the photoelectric properties of the GaN layers and investigated the doping mechanism. The results of this study show that changes in the carrier density are more sensitive to CO2 than to CO. Oxygen as the main donor was found to affect the carrier density and photoluminescence (PL) emission intensities of CO and CO2‐doped GaN, and the carbon incorporation efficiency of these molecules was found to be lower than the oxygen incorporation efficiency. In order to obtain ideal epitaxial GaN layers with a reduced carrier density of 1013 cm−3, the CO and CO2 concentrations in the ammonia source should be less than 100 ppb (CO) and 10−1 ppb (CO2).