There is considerable discrepancy between the amount of X-ray absorption and what is inferred from optical (rest frame UV) as measured along gamma-ray burst (GRB) sight lines, with the former typically an order of magnitude higher than what would be expected from the measurement of neutral element species via optical absorption line spectroscopy. We explored this “missing gas problem” in a sample of 29 GRBs with redshifts in the range 0.7–6.3 by studying the X-ray and optical spectra, as well as the afterglow broadband spectral energy distributions. The low ionisation species detected in the UV are associated with the neutral interstellar medium in the GRB host galaxy, while soft X-ray absorption, which is weakly dependent on the ionisation state of the gas, provides a probe of the total column of gas along the sight line. After careful consideration of any systematic eﬀects, we ﬁnd that the neutral gas consists of 10% of the total gas, and this limit decreases the more ionised the X-ray absorbing gas is, which in our spectral ﬁts is assumed to be neutral. Only a very small fraction of this ionised gas, however, is detected in UV absorption lines with ionisation potentials up to∼200 eV (i.e. Si iv,Civ,Nv,Ovi), which leaves us to postulate that the X-ray excess comes from ultra-highly-ionised, dense gas in the GRB vicinity.