Stomach ulcers are commonly caused by bacteria or by taking non-steroidal anti-inflammatory drugs (NSAIDs). Depending on the cause, your doctor may recommend changes to your lifestyle or medicine to prevent your risk. Things you can do include taking NSAIDs, such as ibuprofen, aspirin and naproxen, with food - this can prevent the drug irritating the lining of the stomach. In some people, the bacteria which resides in the stomach lining can cause irritation, making them more susceptible to developing stomach ulcers. Smoking can also be a contributing factor to developing stomach ulcers, so quitting smoking may reduce your risk.