<s>[INST] connection between two distinct prime numbers $p,q$ such that $p^n=q^2+q+1$ Let $p,q$ be two distinct prime number such that $p^n=q^2+q+1$, where $n \in \Bbb{N}$. I want to proof that, this forces $n=1$.
 [/INST] I borrowed two books on contest problems; this one is An Introduction to Diophantine Equations, by Titu Andreescu, Dorin Andrica, and Ion Cucurezeanu. Most of what is needed for your problem, probably all, is in section 4.2, The Ring of Integers of $\mathbb Q[\sqrt d].$ This is mentioned above by Jack, suggesting working in the Eisenstein integers $\mathbb Z[\sqrt {-3}],$ which is a UFD.
This is a pretty good start...
We have $x^2 + x + 1 = p^n;$ I am not sure yet whether the restriction that $x$ be prime matters. We have, page 168, the unit
$$  \omega = \frac{-1 + \sqrt {-3}}{2}, $$
which is a cube root of $1.$ The main detail is that $\sqrt {-3}$ is irreducible in $\mathbb Z[\sqrt {-3}].$ On page 173 we have some examples of finding gcd of two quantities. Also on page 177, problem 2 is similar to yours, solution takes pages 315-319.  Note that
$$   \omega^2 = -1 - \omega,$$
$$     \omega -  \omega^2 =  \sqrt {-3}. $$
Alright, we have factorization
$$  (x - \omega)(x - \omega^2) = p^n.  $$
We need to know
$$ \gcd(x - \omega, x - \omega^2). $$ If some $\delta$ in the ring divides both, then it divides $     \omega -  \omega^2 =  \sqrt {-3}. $ However, this is irreducible, so
$$ \gcd(x - \omega, x - \omega^2)= 1. $$
It follows that each factor is such a power, that is
$$  x - \omega = (a + b \omega)^n, $$
for ordinary $a,b \in \mathbb Z.$ NOTE: remind me to put in alternatives
$$   x - \omega =  \omega(a + b \omega)^n, \; \; \;    x - \omega =  \omega^2(a + b \omega)^n.  $$
What I have so far is the implication
$ b = \pm 1;  $ let me do exponent $n=5.$
$$  x - \omega = (a + b \omega)^5, $$
$$  x - \omega = a^5 + 5 a^4 b \omega + 10 a^3 b^2 \omega^2 + 10 a^2 b^3 + 5 a b^4 \omega + b^5 \omega^2. $$
Remember $\omega^2 = -1 - \omega,$ so that
$$  x - \omega = (a^5 - 10 a^3 b^2 + 10 a^2 b^3 - b^5)  + (5 a^4 b  - 10 a^3 b^2   + 5 a b^4  - b^5 ) \omega. $$ The coefficient of $\omega$ needs to be $-1,$ that is
$$ (5 a^4 b  - 10 a^3 b^2   + 5 a b^4  - b^5 ) = -1 $$
and
$$ b(5 a^4   - 10 a^3 b   + 5 a b^3  - b^4 ) = -1. $$
Well, $b$ is an ordinary integer, and $b$ divides $-1.$ that is,
$$  b = \pm 1. $$
 Next, we need either
$$ 5 a^4   - 10 a^3    + 5 a   - 1  = -1, $$ or
$$ 5 a^4   + 10 a^3   - 5 a   - 1 = -1. $$ Either way,
divide out by $5a,$
$$ a^3 + 2 a^2 - 1 = 0  $$ OR
$$ a^3 - 2 a^2 + 1 = 0.  $$
The rational root theorem tells us that $a = \pm 1$ as well.
</s>