If we have a function $f:\mathbb{R}\to\mathbb{R}$, given as $f(x)=x^2$,
Let, $$ y=f(x), \text{such that }y\in\mathbb{R}\\ y=x^2\implies \sqrt{y}=|x|\implies\sqrt{y}=x\text{ or }-x\implies x=\pm\sqrt{y} $$ Here I can clearly see that for -ve $y$ there is no corresponding preimage in the domian such that $f(x)=y$, since square root of a -ve number can not be real. Ex: $y=-2$, $x=\sqrt{-2}\notin \mathbb{R}$. Thus not onto.
Now, if we have $g:\mathbb{R}\to\mathbb{R}$, given as $g(x)=|x|$,
Let, $$ y=g(x), \text{such that }y\in\mathbb{R}\\y=|x|\implies y=x\text{ or }-x\implies x=\pm y $$
Now,
I can see from the plot of $y=|x|$ it has no value in the domain corresponds to -ve real values in the codomain thus it got to be not onto.
But from the final equation how can i reach the conclusion that the equation has no solution if $y<0$?. what am I thinking wrong here ?
From $y=|x|$ you can conclude more that just $y=x$ or $y=-x$. You can conclude that $y=x$ if $x\geqslant0$ and that $y=-x$ otherwise. In each case $y\geqslant 0$. In other words, if $y<0$, then the equation $y=|x|$ has no solution.