During its orbit around the four million solar mass black hole Sagittarius A∗ the star S2 experiences significant changes in gravitational potential. We use this change of potential to test one part of the Einstein equivalence principle: the local position invariance (LPI). We study the dependency of different atomic transitions on the gravitational potential to give an upper limit on violations of the LPI. This is done by separately measuring the redshift from hydrogen and helium absorption lines in the stellar spectrum during its closest approach to the black hole. For this measurement we use radial velocity data from 2015 to 2018 and combine it with the gravitational potential at the position of S2, which is calculated from the precisely known orbit of S2 around the black hole. This results in a limit on a violation of the LPI of |βHe-βH|=(2.4±5.1)×10-2. The variation in potential that we probe with this measurement is six magnitudes larger than possible for measurements on Earth, and a factor of 10 larger than in experiments using white dwarfs. We are therefore testing the LPI in a regime where it has not been tested before.