4. Let $F$ be a focus of the ellipse $\frac{x^{2}}{a^{2}}+\frac{y^{2}}{4^{2}}=1(a>0$, and $a \neq 2)$. A line segment $A B$ of length 3 has its endpoints moving on the ellipse. Then, when $|A F| \cdot|B F|$ reaches its maximum value, $a=$ $\qquad$
4. $\frac{8}{3}$ or $\sqrt{3}$.

When $a>2$, let the other focus of the ellipse be $F^{\prime}$, and connect $A F^{\prime}, B F^{\prime}$. Then $\left|A F^{\prime}\right|+\left|B F^{\prime}\right| \geqslant|A B|=3$. Therefore,
$$
|A F|+|B F|=4 a-\left(\left|A F^{\prime}\right|+\left|B F^{\prime}\right|\right) \leqslant 4 a-3 .
$$

Thus,
$$
|A F| \cdot|B F| \leqslant\left(\frac{|A F|+|B F|}{2}\right)^{2} \leqslant\left(\frac{4 a-3}{2}\right)^{2} .
$$

The equality holds if and only if segment $A B$ passes through point $F^{\prime}$, and $|A F|=|B F|=\frac{4 a-3}{2}$. In this case, $A B \perp x$ axis, and $A B$ passes through point $F^{\prime}$. Therefore,
$$
4 c^{2}=\left|F F^{\prime}\right|^{2}=\left(\frac{4 a-3}{2}\right)^{2}-\left(\frac{3}{2}\right)^{2}=4 a^{2}-6 a,
$$

which means $c^{2}=a^{2}-\frac{3}{2} a$.
From $a^{2}=4+\left(a^{2}-\frac{3}{2} a\right)$, we get $a=\frac{8}{3}$.
Similarly, when $0<a<2$, we get $a=\sqrt{3}$.