system
Given the following post, respond as if you're commenting on Reddit:
human
ELI5: How do our stomachs know when we've eaten something bad and need to vomit?
gpt
There are several ways to induce vomiting in humans. Without getting too specific, they are all linked through the "vomiting center" of the brain, also known as the area postrema. This center is capable of responding to many different types of poisons, toxins, conditions, etc. In the case of eating something bad, remember that the stomach is a highly vascularized zone that also happens to have a massive nervous structure, called the enteric nervous system. 

Usually food poisoning that involves vomiting is caused by organisms that have preformed toxins, including but not limited to B cereus and S aureus. Meaning that delicious looking potato salad is teeming with toxins that have been pre-made by the bacterial species to wreak havoc on the consumer. This is why they work so fast (hours). These toxins cause inflammation in the gut and this information is transmitted back to the area postrema. 

After the brain realizes something is not right down there, it stimulates muscles including the abdominal musculature and diaphragm to propel the harmful substance out of the body via forceful contraction. Of course, the cardiac sphincter must be opened (top of the stomach), and pyloric sphincter must be closed (bottom of the stomach) in order to create enough pressure to blow chunks. 


Related: The overwhelming majority of taste types our species is capable of tasting falls in the "bitter" category. This is because throughout human evolution, we have come to realize that bitter tasting food and vegetables are often poisonous. Thus we feel a sense of disgust in response to bitter foods as a protective mechanism to prevent swallowing.