Bell ’ s theorem states that some predictions of quantum mechanics can not be reproduced by a local-realist theory . That conflict is expressed by Bell ’ s inequality , which is usually derived under the assumption that there are no statistical correlations between the choices of measurement settings and anything else that can causally affect the measurement outcomes . In previous experiments , this “ freedom of choice ” was addressed by ensuring that selection of measurement settings via conventional “ quantum random number generators ” was space-like separated from the entangled particle creation . This , however , left open the possibility that an unknown cause affected both the setting choices and measurement outcomes as recently as mere microseconds before each experimental trial . Here we report on a new experimental test of Bell ’ s inequality that , for the first time , uses distant astronomical sources as “ cosmic setting generators. ” In our tests with polarization-entangled photons , measurement settings were chosen using real-time observations of Milky Way stars while simultaneously ensuring locality . Assuming fair sampling for all detected photons , and that each stellar photon ’ s color was set at emission , we observe statistically significant \gtrsim 7.31 \sigma and \gtrsim 11.93 \sigma violations of Bell ’ s inequality with estimated p -values of \lesssim 1.8 \times 10 ^ { -13 } and \lesssim 4.0 \times 10 ^ { -33 } , respectively , thereby pushing back by \sim 600 years the most recent time by which any local-realist influences could have engineered the observed Bell violation .