While stress and anxiety cannot cause a stomach ulcer, they can weaken your immune system and make it difficult for your body to fight off infections, which could leave you susceptible to stomach ulcers.