Not necessarily. Let $g\colon\mathbb{R}\to\mathbb{R}$ be such that $g\in L^2(\mathbb{R})$ but $g\not\in L^\infty(\mathbb{R})$. For instance, we could take $ g(x)=\sum_{n=0}^\infty n\,\chi_{[n,n+2^{-n}]}(x), $ where $\chi_{A}$ is the characteristic function of the set $A$. Let $ P_y(x)=\frac{1}{\pi}\,\frac{y}{x^2+y^2},\quad x\in\mathbb{R},\quad y>0, $ be the Poisson kernel. Then $u(x,y)=P_y\ast g(x)$ is a harmonic function on the upper half-plane such that $u(x,0)=g(x)$. This last equality holds:
- In the $L^2$ sense: $\lim_{y\to0}\int_{-\infty}^\infty|u(x,y)-g(x)|^2\,dx=0$
- In the non tangential sense: given $\alpha>0$, for almost all $\xi\in\mathbb{R}$, $\lim_{(x,y)\to(\xi,0),x\in \Gamma(\xi)}u(x,y)=g(\xi)$, where $\Gamma_\alpha(\xi)=\{(x,y):|x-\xi| \le\alpha\,y\}$.
Let $v(x,y)$ be the conjugate function of $u$. Then $f(z)=u+i\,v$ is analytic on the upper half-plane, and $f(x)=g(x)+Hg(x)$, where $Hg$ is the Hilbert transform of $g$. Since $H$ is a bounded operator on $L^2$, it follows that \int_{-\infty}^\infty|f(x)|^2\,dx<\infty.