5. Let the complex number $z=\cos \theta+i \sin \theta\left(0^{\circ} \leqslant \theta \leqslant\right.$ $\left.180^{\circ}\right)$, and the complex numbers $z, (1+i)z, 2\bar{z}$ correspond to three points $P, Q, R$ on the complex plane. When $P, Q, R$ are not collinear, the fourth vertex of the parallelogram formed by segments $PQ, PR$ is $S$. Then the maximum distance from point $S$ to the origin is
5.3.

Let the complex number $w$ correspond to point $S$. Since $Q P R S$ is a parallelogram, we have
$$
\begin{aligned}
w+z & =2 \bar{z}+(1+\mathrm{i}) z, \text { i.e., } w=2 \bar{z}+\mathrm{i} z . \\
\therefore|w|^{2} & =(2 \bar{z}+\mathrm{i} z)(2 z-\mathrm{i} \bar{z}) \\
& =4+1+2 \mathrm{i}\left(z^{2}-\bar{z}^{2}\right)=5-4 \sin 2 \theta \\
& \leqslant 5+4=9(\text { when } \theta=135 \text {, the equality holds }) .
\end{aligned}
$$

Thus, $|w|_{\text{max}}=3$.