Can't get or keep an erection so you can have sex? That's what doctors call erectile dysfunction, or ED.
If it happens only occasionally, it's not likely to be serious. All men have problems with erections at some time in their lives.
If it slowly but consistently gets worse, there's probably a physical cause. This is generally what happens with chronic impotence.
If it happens suddenly but you're still stiff early in the morning and can get an erection while masturbating, that suggests your mind...