The experiment of Krasznahorkay \textit{et al} observed the transition of a $\rm{^{8}Be}$ excited state to its ground state and accompanied by an emission of $e^{+}e^{-}$ pair with 17 MeV invariant mass. This 6.8$\sigma$ anomaly can be fitted by a new light gauge boson. We consider the new particle as a $U(1)$ gauge boson, $Z'$, which plays as a portal linking dark sector and visible sector.
%Dark matter is assumed to be a fermionic particle and annihilates into new gauge boson pair in p-wave contribution.
In particular, we study the new $U(1)$ gauge symmetry as a hidden or non-hidden group separately. The generic hidden $U(1)$ model, referred to as dark $Z$ model, is excluded by imposing various experimental constraints. On the other hand, a non-hidden $Z'$ is allowed due to additional interactions between $Z'$ and Standard Model fermions. We also study the implication of the dark matter direct search on such a scenario. We found the search for the DM-nucleon scattering cannot probe the parameter space that is allowed by $\rm{^{8}Be}$-anomaly for the range of DM mass above 500 MeV. However, the DM-electron scattering for DM between 20 and 50 MeV can test the underlying $U(1)$ portal model using the future Si and Ge detectors with $5e^{-}$ threshold charges.