In this work, analysis of nonlinear vibration of piezoelectric nanobeam in a thermo-magnetic environment embedded in Winkler, Pasternak, quadratic and cubic nonlinear elastic media for simply supported and clamped boundary conditions is presented. With the considerations of Von- Karman geometric nonlinearity effect and with the aids of nonlocal elasticity theory as well as Euler–Bernoulli beam model, the equation of motion for the nanobeam is derived using Hamilton’s principle. The nonlinear dynamic model is solved using Galerkin-decomposition coupled with iteration perturbation method. From the parametric studies, it is shown that the frequency of the nanobeam increases at low temperatures but decreases at high temperatures. The nonlocal parameter decreases the frequencies of the piezoelectric nanobeam. An increase in the quadratic nonlinear elastic medium stiffness causes a decrease in the first mode of the nanobeam with clamped-clamped supports and an increase in all modes of the simply supported nanobeam at both low and high temperatures. When the magnetic force, cubic nonlinear elastic medium stiffness, and amplitude increase, there is an increase in all mode frequencies of the nanobeam. An increase in the temperature change at high temperature reduces the frequency ratio but at low or room temperature, an increase in temperature change, increases the frequency ratio of the structure nanotube. The significance of this study is evident in the design and applications of nanobeams in thermal and magnetic environments.