The secondary, substitute habitats are becoming more important for the survival of many valuable plant species, including medicinal plants—for example, bearberry Arctostaphylos uva-ursi. The aim of the conducted research is to compare the ability of A. uva-ursi to accumulate heavy metals in leaves from railways (anthropogenic substitute habitat) and the natural habitats (pine forests). We measured the concentration of five heavy metals (Cd, Hg, Ni, Pb, and Zn) in plant material and in the soil. The bioaccumulation factor was also calculated. Moreover, we measured biotic factors including A. uva-ursi height and abundance, along with the plant diversity indices, in the investigated plots. The presented results reveal that (1) none of the parameters concerning the content of the selected heavy metals described in the currently applicable legal acts were exceeded, (2) A. uva-ursi does not show the potential for heavy metal accumulation, except for zinc and partially mercury, (3) its individuals in the natural habitats are lower, (4) the abundance (percentage cover) of A. uva-ursi is the lowest in the natural habitat, and (5) the value of the Shannon–Wiener diversity index is the highest in the vegetation patches with A. uva-ursi developed in natural habitats.