  The relativistic degrees of freedom ($N_{\rm eff}$) is one of the crucial
cosmological parameters. The precise measurement of $N_{\rm eff}$ at the time
of cosmic microwave background formation, by Planck 2018 can be used to
understand the new fundamental interactions, in particular involving light
mediators. Presence of any new particle with sufficient energy density and
sizeable interactions with Standard Model particles at the temperature around
$\sim$ MeV can significantly alter the neutrino decoupling and hence $N_{\rm
eff}$. Thus the bound on $N_{\rm eff}$ can place stringent constraints on
various beyond Standard Model paradigms involving light particles. $U(1)_X$
models are among such scenarios and are widely studied in several aspects. In
this work, we consider several popular $U(1)_X$ models with light $Z'$ boson
like $U(1)_{B-L}$, $U(1)_{B - 3L_i}$, $U(1)_{B_i - 3 L_j}$, $U(1)_{L_i - L_j}$;
$i,j =1,2,3$ being the flavour indices and study their impact on $N_{\rm eff}$.
We also examine the constraints from ground based experiments like Xenon1T,
Borexino, trident, etc. Our analysis shows that for light mass $M_{Z'} \lesssim
\mathcal{O} (\rm{MeV})$ the $N_{\rm eff}$ provides the most stringent
constraints on the $Z'$ mass and coupling, far exceeding the existing
constraints from other experiments.
