Melamine-formaldehyde (MF)rigid foams with high closed cell content were prepared via oven heating process, using MF prepolymer prepared from melamine and paraformaldehyde as a matrix, cyclohexane as the foaming agent, dimethyl silicon oil as the foam stabilizers, hydrochloric acid as the catalyst. The effect of MF prepolymer viscosity, foaming temperature, amount of catalyst on morphology, closed cell content, apparent density, water absorption and compressive strength of MF rigid foams were systematically studied. The optimized foaming conditions are as follows: the viscosity of MF prepolymer ranges from 35 Pa·s to 45 Pa·s, the foaming temperature is 125°C and the content of the catalyst is 0.65 wt%. The as-prepared MF foams showed the best comprehensive performance with closed cell content of 83.5%, apparent density of 62 kg·m−3, water absorption of 12.0%, compressive strength of 292kPa, thermal conductivity of 0.033 W m−1 K−1 and limiting oxygen index (LOI) of 36%. Compared to conventional organic foams, MF rigid foams possess low water absorption, excellent thermal insulation and flame retardancy due to high closed cell content, and can be expected to be used as thermal insulation material for building exterior walls.