First note that $a$ must be equal to or greater than $p_{k+1}$, otherwise some prime divisor $q$ of $a$ would divide the RHS, but not the LHS. So, it is obvious that $n<k$. Now let us consider the smallest prime divisor $q$ of $n$. As $n<k<p_k$, $q$ is one of the primes $p_1,p_2,...,p_{k-1}$.
First note that $a$ is odd, not divisible by 3 and comparing both sides $(mod 3)$, we have $n$ is odd too.
Now note that $a^q+1\equiv a+1(mod q)$, so $q\mid (a+1)$. Again, using the lifting the exponent lemma, we have, $v_q (a^q+1)=v_q (a+1) +v_q (q) >1$, and also $(a^q+1)\mid (a^n+1)$. And so $v_q (a^n+1) >1$. Which isn't possible as $(a^n+1)$ is the product of some different prime numbers. So we conclude that there is no solution.