4. Let the arithmetic sequence $\left\{a_{n}\right\}$ have a common difference of $d(d \neq 0)$, and the sum of the first $n$ terms be $S_{n}$. If the sequence $\left\{\sqrt{8 S_{n}+2 n}\right\}$ is also an arithmetic sequence with a common difference of $d$, then the general term of the sequence $\left\{a_{n}\right\}$ is $a_{n}=$ $\qquad$
Solve:
$S_{n}=n a_{1}+\frac{n(n-1)}{2} d \Rightarrow 8 S_{n}+2 n=8 n a_{1}+4 n(n-1) d$, Let $\sqrt{8 a_{1}+2}=m$,
then $\sqrt{8 S_{n}+2 n}=m+(n-1) d \Rightarrow 8 n a_{1}+4 n(n-1) d=[m+(n-1) d]^{2}$
\[
\begin{array}{l}
\Rightarrow\left(d^{2}-4 d\right) n^{2}+\left(-2 d^{2}+2 m d-8 a_{1}+4 d-2\right) n+m^{2}+d^{2}-2 m d=0 \\
\Rightarrow\left\{\begin{array} { l } 
{ d ^ { 2 } - 4 d = 0 , } \\
{ m ^ { 2 } + d ^ { 2 } - 2 m d = 0 }
\end{array} \Rightarrow \left\{\begin{array}{l}
d=4, \\
m=4 .
\end{array} \text { Substituting into }-2 d^{2}+2 m d-8 a_{1}+4 d-2=0 \Rightarrow a_{1}=\frac{7}{4} .\right.\right.
\end{array}
\]

Therefore, the general term of the sequence $\left\{a_{n}\right\}$ is $a_{n}=4 n-\frac{9}{4}\left(n \in \mathbf{N}^{*}\right)$.