We study the effect of inhomogeneities in the matter distribution of the un
iverse on the Faraday rotation of light from distant QSOs and derive new li
mits on the cosmological magnetic field. The matter distribution in the uni
verse is far from homogeneous, and for the redshifts of interest in relatio
n to rotation measures (RMs), it is well described by the observed Ly alpha
forest. We use a lognormal distribution to model the Lya forest, and we as
sume that a cosmological magnetic field is frozen into the plasma and there
fore is a function of the density inhomogeneities. The Ly alpha forest resu
lts are much less sensitive to the cosmological magnetic field coherence le
ngth than the results for a homogeneous universe, and they show an increase
in the magnitude of the expected RM for a given field by over an order of
magnitude. The forest also introduces a large scatter in RMs for different
lines of sight, with a highly non-Gaussian tail that renders the variance a
nd the mean RM impractical for setting limits. The median \RM\ is a better
statistical indicator that we use to derive the following limits using the
observed RMs for QSOs between z = 0 and z = 2.5. We set Omega(b)h(2) = 0.02
and get, for cosmological fields that are coherent across the present hori
zon, BH0-1 less than or similar to 10(-9) G in the case of a Ly alpha fores
t that is stronger than the limit for a homogeneous universe, B-H0-(h)(1) l
ess than or similar to 2 x 10(-s) G; for a 50 Mpc coherence length, the inh
omogeneous case gives B-50Mpc less than or similar to 6 x 10(-9) G, while t
he homogeneous limit is B-50Mpc(h) less than or similar to 10(-7) G; and fo
r coherence length equal to the Jeans length, B-lambda J less than or simil
ar to 10(-8) G for the Ly alpha case, while B-lambda J(h) less than or simi
lar to 10(-6) G.