For a prime number $p > 2$ the following formula for the Legendre symbol holds:
$$\left(\frac {-1}p\right)=(-1)^{\frac{p-1}{2}}.$$
More in detail, this law states that $$\left(\frac {-1}p\right)=\begin{cases}1&\text{if }p\equiv 1\mod 4,\\-1&\text{if }p\equiv -1\mod 4.\end{cases}$$
In particular, the congruence $x^2(p)\equiv -1(p)$ is only solvable, if $p$ has the form $p\equiv \pm 1\mod 4,$ and any odd prime factor of the integer $x^2+1$ has the form $p\equiv \pm 1\mod 4.$
Proofs: 1