Stress, both in and out of the bedroom, can make it difficult for a man to achieve an erection. Depression, anxiety, and the medications to treat them may also contribute to impotence.