4. Given that $a$ is a real number, the equation about $x$
$$
27 x^{2}+2 a^{2} x+a=0
$$

has real roots. Then the maximum value of $x$ is ( ).
(A) 0
(B) $-\frac{3}{2}$
(C) $-\frac{1}{3}$
(D) $\frac{1}{6}$
4.D.

Consider the original equation as an equation in terms of $a$, and transform it into $2 x a^{2}+a+27 x^{2}=0$.
When $x=0$, $a=0$;
When $x \neq 0$, $\Delta=1-216 x^{3} \geqslant 0$, solving this yields $x \leqslant \frac{1}{6}$.
When $a=-\frac{3}{2}$, $x=\frac{1}{6}$.
Therefore, the maximum value of $x$ is $\frac{1}{6}$.