The density functional theory RB3LYP/6-311＋＋G(d,p) was employed to study the mechanism of nitrosobenzene with formaldehyde in gas phase and solvents on a singlet potential energy surface. Two reaction paths, the concerted and the stepwise mechanisms were found, both of which produce the experimental product: N-phenylhydroxamic acid C6H5NOHCHO. The calculated results show that the stepwise mechanism is the most favorable one in the gas phase. The solvent effect of the reaction has been studied using the conductor-like polarizable continuum model respectively in the solvents of water, ethanol, acetonitrile, dichloromethane, THF and cyclohexane. The solvation effect reduces the activation energy, but the reaction of nitrosobenzene with formaldehyde is not sensitive to the solvent polarities. In both gas phase and solvents, the stepwise mechanism of nitrosobenzene with formaldehyde is the most favorable one.