40ppm! I'd die! That much nitrate is fatal to bowheads. What would I do without rainbows? Well there's the answer... die.
Mollies shouldn't be bothered by it though... just how high is it? If it's over 70 or so you might have to be worried.
When I tried to keep mollies I was plagued by just this problem. I could not keep them healthy. They would look fine for a week or so, then develop the shimmies, the weight would melt off them no matter what I fed, and they would clamp their fins and rest on the bottom or float, and eventually drop dead no matter what meds I tried. They were also plagued by ich, fungus and columnaris that never seemed to affect anything else. The answer was not the one I wanted to hear because it basically means I can't keep mollies while on this water supply. The water was too soft for them.
The molly you buy at the pet shop is a hybrid, a mixture of several species. Some mollies are freshwater, some are brackish, but they are all essentially hardwater species and they need the water warm. If your water is very soft, you will need to add a lot of salt to it (preferably marine salt, which contains not only the standard 'salt' sodium chloride but also magnesium, carbon and calcium salts which are the things that make water hard). If the only fish you have in your tank are mollies this is perfectly ok, the problem happens when you've got mollies in a community and can't add salt because it will bother the other fish.
Add salt, keep the water very warm, and switch to the hardest water possible. Then see what happens. It's probably too late for the molly that's sick at the moment but it will stop this from becoming a recurring nemesis for you like it did for me. I feel so horrible when i think of the four or five beautiful mollies I killed before I worked out what was wrong
