Magnetic anisotropy energy (MAE) and magnetoelastic (ME) stress in epitaxial Cu(4 nm)/Ni90Fe10/Cu(160 nm)/Si(001) films have been studied at room temperature as a function of the permalloy film thickness (2 nm⩽tPm⩽50 nm). Magnetostatic energy keeps the magnetization within the film plane, although surface and magnetoelastic anisotropy energy favor magnetization normal to the film plane. The direct measurement of the magnetoelastic stress shows the ME coefficients to depend linearly on the strain, ε, for the ME coefficient. As a result, a second-order magnetoelastic contribution, proportional to ε2, has to be included in the MAE. Using both sets of measurement we determine two second-order ME coefficients, M1γ,2=−0.3×107 J/m3 and M2γ,2=8.3×107 J/m3, and the surface magnetic anisotropy constant, Ksur=0.4 mJ/m2.