The best way to prevent a drain fly infestation in the future is to make sure your drains are clean and dry. Do not let drain water sit stagnant. If you have drains in your home that you rarely use, run water through them weekly.