Gravitational redshift
But, if photons move towards a place with strong gravity, like towards a star or black hole, they look like they are gaining more energy. This is called gravitational blueshift, and it's like moving light towards the blue end of the spectrum.