I am assuming that it isn't a medical thing here as he does get it up in the first place, so to speak.
It is psychological thing and worry is the reason, it does have that effect. A penis becomes erect when blood flows into it, anxiety causes blood vessels to constrict , this can have the effect you are seeing.
In the first instance it was probably nerves about with being with a new partner and not wanting to disappoint. Subsequently he now has not only has the original worries but he now has the memories of not performing last time so the pressure to perform is increased, therefore he becomes even more anxious and it becomes a vicious circle.
The best way to solve this is to not make him feel any pressure to have penetrative sex, let him know you are happy doing whatever he feels comfortable with. Maybe let him pleasure you, tell him what you like, this is a turn on for guys. Or maybe just kiss, cuddle and touch. Once he feels that the pressure is off him, he will relax, nature will take it's course and all will be well in the jungle.