Scattering of an elastic wave by cavities yields dynamic stress concentration around the cavities. When the characteristic size of the cavities shrinks to the nanometer scale, the surface effect becomes prominent. Based on a recently proposed theory of surface elastodynamics, the dynamic stress concentration factor (DSCF) in the scattering of a plane P wave by a spherical nanocavity has been investigated. Not only the surface energy effect but also the surface inertial effect is considered. The former depends on two easily-determined surface material parameters, namely, the bulk surface energy density and the surface relaxation parameter, whereas the latter is related to the surface mass density. Interestingly, due to the surface relaxation of nanocavity, a constant elastic field exists in the elastic medium even without any dynamic loadings. Furthermore, it is found that when the radius of cavity is at the nanoscale, the surface energy effect as well as the surface inertial effect has a significant influence on DSCF. The former attenuates the maximum DSCF, whereas the latter enhances it. With the increasing incident P wave frequency, the dominant role transits from the surface energy effect to the surface inertial effect. This indicates that the DSCF around the nanocavity can be properly tuned by adjusting the incident wave frequency, the cavity radius and the surface material parameters. The results can not only enable a deeper understanding of the surface effects on DSCF around the nanocavities, but also provide a guide for designing nanoporous materials exhibiting efficient dynamic performance.