Why would a guy not be able to stay erect?

The guy I am seeing, wasn’t able to stay erect, And he seemed like he was in a bad mood after and I tried to talk to him and ask why he seemed irritated or something but he said he was tired and going to sleep.. so I felt like it was because of me because I overthink.. he had been drinking so I don't know if that could be why. . We haven’t slept together in awhile either cuz we were arguing a-lot/not speaking but we’ve been on good terms lately..
Why would a guy not be able to stay erect?
Post Opinion