There are three types of worlds in the universe that might support life. Habitable planets orbit stars from which they could obtain the energy necessary to maintain a surface biosphere. Tidal heating due to the gravitational interaction with the star, or internal heat due to the formation process and radiogenic elements might also contribute to the biosphere energy of planets.
Habitable moons might support a subsurface biosphere by tidal/internal heating (i.e. Europa) but also a surface one if the parent planet orbits in the habitable zone of the star (i.e. sci-fi Pandora).
Habitable nomads (aka rogue, orphan, free-floating planets) are only limited to their internal energy unless they are also subjected to tidal heating due to a companion (i.e. sci-fi Bronson Beta). Other more exotic energies sources have been proposed to support a biosphere (i.e. dark energy).