Unless properly corrected for, the existence of intergalactic dust will introduce a redshift-dependent magnitude offset to standard candle sources. This would lead to overestimated luminosity distances compared to a dust-free universe and bias the cosmological parameter estimation as derived from, e.g., Type Ia supernova observations. In this paper, we model the optical extinction and X-ray scattering properties of intergalactic dust grains to constrain the intergalactic opacity using a combined analysis of observed quasar colours and the soft X-ray background. Quasar colours effectively constrain the amount of intergalactic dust grains smaller than m, to the point where we expect the corresponding systematic error in the Type Ia supernova magnitude–redshift relation to be sub-dominant. Soft X-ray background observations are helpful in improving the constraints on very large dust grains for which the amount of optical reddening is very small and therefore is more difficult to correct for. Our current upper limit corresponds to ∼0.25 mag dimming at optical wavelengths for a source at redshift z = 1, which is too small to alleviate the need for dark energy but large in terms of relative error. However, we expect it to be possible to lower this bound considerably with an improved understanding of the possible sources of the X-ray background, in combination with observations of compact X-ray sources such as active galactic nuclei.