The metallicity and dust-to-metals ratio of the Galaxy are fundamental parameters in understanding the interstellar medium (ISM). Currently, there is still some uncertainty surrounding these parameters. In this paper, the dust-to-metals ratio in the Galaxy is determined using the photoelectric absorption of the soft X-ray afterglows of a large sample of several hundred gamma-ray bursts (GRBs) to determine the metal column density in combination with Galactic dust maps to determine the line-of-sight dust extinction through the Galaxy in the direction of the GRB. GRB afterglows often have large extragalactic soft X-ray absorptions and therefore the GRB sample's upper-bound will define the Galactic dust-to-metals relation. Using a two-dimensional two-sample Kolmogorov-Smirnoff test, we determine this upper-bound and so derive the dust-to-metals ratio of the Galaxy. We find N H = 2.2 +0.3 −0.4 × 10 21 cm −2 A V asassuming solar, Anders & Grevesse (1989, Geochim. Cosmochim. Acta, 53, 197), metallicity. This result is consistent with previous findings using bright X-ray sources in the Galaxy. Using the same technique but substituting the H i maps from the Leiden-ArgentineBonn survey for the dust maps, allows us to place a limit on the metallicity in the Galaxy. We find a metallicity consistent with the Anders & Grevesse (1989) solar values often used in X-ray fitting. Based on this and previous studies, we suggest that the metallicity of a typical ISM sightline through the Galaxy is ∼0.25 dex higher than the current best estimate of the solar metallicity. We further show that the dust-to-gas ratio seems to be correlated with the total gas column density, and that this may be due to the metallicity gradient observed toward the Galactic centre. Based on the non-constant nature of the dust-to-gas ratio, we propose that the dust column density, at N H = 2.2 × 10 21 cm −2 A V , represents a better proxy for the soft X-ray absorption column density than H i maps.