  We consider the gauged $U(1)_{B-L}$ model and examine the situation where the
sterile neutrino is a dark matter candidate produced by the freeze-in
mechanism. In our model, the dark matter $N$ is mainly produced by the decay of
a $U(1)_{B-L}$ breaking scalar field $\phi$. We point out that the on-shell
production of $\phi$ through annihilation of the $U(1)_{B-L}$ gauge field $Z'$
plays an important role. We find that the single production of $Z'$ from the
photon bath is one of the main production processes of $Z'$. To prevent $N$
from being overproduced, we show that the $U(1)_{B-L}$ gauge coupling constant
$g_{B-L}$ must be as small as $10^{-13}$-$10^{-10}$. We also consider the case
where the decay of $\phi$ into $N$ is kinematically forbidden. In this case,
$N$ is generated by the scattering of $Z'$ and the $g_{B-L}$ takes values of
$10^{-7}$-$10^{-6}$, which can be explored in collider experiments like FASER.
