I used to have exactly the same problem with the flies (I think mine were a species of fungus gnats.) It got to a point where they were infesting my entire house.
Here's what I did to completely remove them: (Sorry it's long—I just want to be as specific as possible.) Some of the stuff might seem kind of ridiculous and tedious, but I tried cleaning the bin like I normally would several times, and the flies would always come back, since even a few fly/egg/larvae left can infect your entire colony. However, you might not want to do all of this if your colony is small. If this is the case, just clean it very well along with fly-proofing the bin, and you should be fine.
Preparation:
1. Get a decent size bin that will allow you to temporarily store the entire roach colony in. This is done to ensure the fly population is completely eradicated in your house and the roach container before moving them back in. (I used a separate container since I could see lots of larvae and eggs around the roach container sides and lid of my main container.)
2. Make sure this container has an air tight lid. I used a large cardboard box (with a trash bag lining inside so they can’t crawl up) and used a piece of cardboard as the lid and taped it to the container
3. Cut ventilation holes on the lid and tape/glue a fine screen over them. Make absolutely sure that the material you use will not allow the flies to pass through. I cut up nylon stockings for this.
Cleaning: (This might take a very long time depending on the colony size and how infected it is)
1. Take the roach bin outside along with the above bin and another small container that you’ll use to transport “clean” roaches to the temporary bin (I used a small trash can for this one.)
2. Keep the temporary bin somewhat far away from the roach bin and put several new egg crates in there (the amount depending on your colony size).
3. Open the roach container and wait for a few hours to let the majority of the flies leave.
4. Start cleaning the roach bin. First shake off all of the roaches from the egg crates into the same bin and throw the used egg crates away. Don’t shake it into the small container as you might drop some larvae.
5. Take the roaches out by a small handful at a time and carefully inspect them for flies/larvae. Put them in the small cleaning bin.
6. When the cleaning bin gets full on the bottom, carefully inspect the roaches for flies and then once it’s clean dump them into the temporary bin.
7. Repeat until done and then wash the original roach container thoroughly.
Wait: (Now you should have the temporary container full of your colony and whatever food they might need.)
1. Store the temporary bin in a closed off location of the house where the flies won’t be able to get at too easily. Keep in there for 1-2 weeks, which should be enough time for eggs/larvae to grow the point you can see them in Phase 2 cleaning (below), but not enough time to mature into adult flies. Be very careful when feeding/watering the roaches, to not let any flies in!
2. Now is the time to completely get rid of the flies in your house using hammerhead’s method (see above.) I also found that sticky fly ribbon (flypaper) hung over a cup of apple cider vinegar works very well.
3. Make the permanent roach bin fly-proof: I had to glue strips of nylon stockings over the larger gapped ventilation screen since I saw flies coming in and out of here. Also, make sure the flies cannot get into the bin through any small cracks between the lid and the container.
Phase 2 of Cleaning (almost done!): I would really recommend doing this part well, since there probably is going to be a few leftover flies/larvae in the temporary bin. (It takes only a few to infest again!)
1. Basically do the same thing as the first cleaning part, but this time, transfer the roaches into the permanent bin. I would suggest doing this inside, in the room where you had the temporary bin quarantined, since there should be fewer flies in the house now.
This process seems to have worked for me, and hopefully it will help you or anyone else who is struggling with this problem! It’s a lot of work, but well worth it in the end. Feel free to PM me if you have any questions.
P.S. If the roach colony is starting to smell, or you need more air circulation in the bin, I have found a way to solve this—just PM me