https://assoc-redirect.amazon.com/g/r/https://www.amazon.com/s/ref=as_at/?creativeASIN=lawngarden&imprToken=CTP.mdh0hf6YasxRRa6HWA&slotNum=5&url=search-alias=lawngarden&field-keywords=nematodes&linkCode=w61&tag=sensig1-20&linkId=f67eb85fc8a60deac72ab34856e1b11d" rel="nofollow noopener" target="_blank">Beneficial N ematode s are microscopic roundworms that seek out and kill 200 different insects in soil or growing medium. Hydrogen peroxide and Diatomaceous earth work too but also kill beneficial bugs & microscopic creatures needed for good healthy soil here's where I buy mine they are guaranteed live https://www.arbico-organics.com/product/nemattack-beneficial-nematodes-sf-steinernema-feltiae/beneficial-nematodes
For fly and gnat problems in outdoor compost piles, I suggest burying each new addition of scraps in the pile and then covering the site with leaves or grass clippings. Leaves and grass clippings are not attractive to these pests, and should keep them at bay.
Fungus gnats often remain near potted plants and run across (or rest on) growing media, foliage, compost, and wet mulch piles. ... They eat organic mulch, leaf mold,grass clippings, compost, root hairs, and fungi.
Just sprinkle ground cinnamon on your compost! Read it on Pinterest, works for me