Recently, atomic nitrogen densities of 50-500 million/cu cm were inferred in the daytime thermosphere from studies of the NI(2D-4S) 5200 A emission and from the photochemistry of various ion species using data measured by the Atmosphere Explorer-C satellite. In this paper we use the photochemistry of NO(+) and O2(+) at night to determine nocturnal N(4S) densities in the thermosphere. We present evidence for a missing source of NO(+) and a missing sink for O2(+) at night and show that this can be adequately supplied by the reaction O2(+) + N yields NO(+) + O if the N density at 200 km is about 7 million/cu cm. The atomic nitrogen has an important effect on studies of the 6300 A airglow. The omission of N in calculations of O(1D) using ground-based data results in an overestimate of the rate coefficient for quenching of O(1D) by N2.