Although the idea of zebras not getting ulcers was popularized in a book titled "Why Zebras Don't Get Ulcers" by Robert Sapolsky, zebras can, in fact, get ulcers. In equines, which includes zebras, ulcers are mainly caused by an excess of stomach acid due to restricted grazing.
Equines are designed to graze almost constantly throughout the day. In captivity, they are often fed two to three small meals each day, which results in long periods without food. This results in overproduction of their natural stomach acids, which damages their stomach lining and leads to ulcers. Stress exacerbates this condition, but a lack of natural grazing is the primary cause. Zebras also can get ulcers in other areas, including their hooves. Ulcers in wild zebras, like other wild equines, are extremely rare because the animals are reacting to normal stresses and eating the diet they evolved to consume.