There can be traces of cockroach parts in coffee, especially in lower-quality, pre-ground coffee. The U.S. Food and Drug Administration (FDA) allows a certain amount of insect contamination, including cockroach fragments, in food products like coffee. This is because coffee beans, especially green coffee, can be infested with insects during growing, harvesting, and storage before processing. Up to 10% of green coffee beans might contain some insect infestation or damage, and small insect parts can end up ground into the coffee. However, specialty and higher-quality coffees usually undergo stricter inspections and are less likely to contain such contaminants. The presence of cockroach contamination has raised allergy concerns, especially for people allergic to shellfish, due to cross-reactivity of proteins found in both.
Additionally, the conditions around coffee machines can attract actual cockroaches but that's separate from the issue of insect parts in the coffee itself.