Prove that $5$ is the only prime $p$ such that $3p + 1$ is a perfect square

Prove that $5$ is the only prime $p$ such that $3p + 1$ is a perfect square.

I started off with assuming that $p$ is odd (since $2$ clearly does not satisfy). This would mean that $3p + 1$ is even. Since if a perfect square is even, it has to be divisible by four, it would mean that $4|3p + 1$.

If $p \equiv 1\pmod 4$, $3p + 1 \equiv 0\space \pmod 4$. All other possible residues of $p \pmod 4$ don't work out. This implies that our proof can be reduced to finding all $m$ such that $3(4m + 1) + 1 = (2n)^2$, or $3m + 1 = n^2$, which looks a lot like our first expression, except, here $m$ does not have to be a prime.

It just remains to be proven that the only $m$ such that $4m + 1$ is a prime and $3m + 1$ is a perfect square is $1$. I don't know where to go from here.


Hint: If $3p +1 = n^2$, then $ (n-1)(n+1) = 3p$.

What does this tell you about $n$? Why is there only 1 solution?