The black worms sometimes found in a toilet are not actually worms. They are the larvae of the common black drain fly from the family Psychodidae. The common black drain fly often lives in semi-aquatic habitats, so residential bathrooms often end up being their new home. Larvae are hatched out of eggs in aquatic environments, such as a toilet or sink.
To prevent larvae from hatching in the toilet or sink, it is best to clean the toilet or sink with bleach often. To get rid of larvae already present, make sure to remove any potential food sources from the bathroom. The common black drain fly eats leftover food as well as hair plugs found in the drains of sinks and bathtubs. Clogs in the sewage lines could also be an issue, so using liquid drain-clog remover can be helpful. Larvae morph into adult flies within a few days of hatching. A key component of eliminating the larvae is eliminating the adults. Within 20 days, most drain flies die, but if they continue to reproduce, they are likely to produce a constant cycle of eggs, larvae and adults in the bathroom. Clean well to prevent further infestations of the bathroom.