Free thermal vibration analysis of nanobeams surrounded by an elastic matrix is examined via nonlocal elasticity and Timoshenko beam theories in this article. Elastic matrix is formulated with a two-parameter elastic foundation modelled by combining Winkler and Pasternak assumptions. The equation of motion for free vibration is reached via Hamilton's principle and solved by analytical method (separation of variable). However, since the separation of variable cannot be applied for boundary conditions other than simply supported nano beams, a weighted residue-based finite element formulation is developed. Within the scope of numerical results, firstly, it is understood from the comparisons given for nondimensional frequencies that the nonlocal finite element formulation has a high accuracy and then, using this formulation, nondimensional frequencies of nanobeams with different boundary conditions are computed under different parameters. Additionally, the detailed discussions of the numerical results are presented. Finally, by giving some general results, the effect of size dependency and environmental factors on the dynamic behavior of nanobeams is expressed.