One of the mainstays of preventing IBS is preventing gastroenteritis (inflammation of the stomach and intestines and the tissue that lines them). Gastroenteritis can happen with a viral, bacterial, or parasite infection. It may also occur when someone is stressed or doesn’t sleep well. This means that to prevent IBS, good hand hygiene, healthy diet, physical activity, and management of underlying psychiatric conditions and stress is very important.