P-traps are the only thing standing between you and the uncontrolled release of sewer gases throughout your house. There's one connected to every drain and inside every toilet. When you detect a sewer gas smell in the bathroom or anywhere else, either one of the traps has gone dry, there's a crack in a pipe somewhere or the toilet isn't sealed properly to the floor, allowing the gases to bypass its internal trap.
Why Traps Run Dry
Every P-trap has a pool of water in its inverted "P" section of pipe, and the water effectively seals sewer gases inside the pipes. There's one condition in the drain system that can empty traps, though, and that's blocked vents.
The vent system, which terminates in the vent stack on the roof, allows air into the pipes to equalize the pressure so flowing water doesn't create suction. When the vents get blocked, not only will you smell sewer gases, which are flammable as well as noxious, you'll also notice slow draining and hear strange gurgling sounds from the drains. The gurgling is the sound of water being sucked out of the trap.
More often than not, the problem is caused by debris or ice blocking the main vent stack. Things will return to normal when you or a plumber you hire clears the blockage. In some cases, a plumber may need to reach into the vent stack with an auger to clear something deep inside, which should stop the sewer gas smell you've been noticing.
Sewer Gas From a Toilet
No toilet, even a well-used one, should smell. When you detect sewer odors and track them to the toilet, they're probably coming from underneath through a malfunctioning wax ring. If the problem is advanced, you may even see water on the floor around the base of the toilet. That's a sign that you have to act quickly because if you don't, the water will rot the subfloor, and you'll have an expensive repair on your hands.
To fix the problem, you'll have to remove the toilet so you can see what's going on. It could be that the toilet flange is recessed below the floor and the wax ring isn't thick enough to make a seal. You can fix this by replacing it with an extra-thick wax ring or installing a flange extender, which is a plastic ring that gets screwed to the top of the flange.
If the floor is already wet and spongy, you probably won't be able to get a good seal no matter what you do until you fix the subfloor. This is a somewhat major project because it involves removing the damaged part of the floor, but you have to do it. If it's beyond your budget, it's best to pull the toilet, stuff a rag into the waste pipe, put a bucket over it and leave it until you can afford the repair.
Sewer Gases from Cracked or Loose Pipes
P-trap sewer gas is easy to localize because the smell gets stronger as you approach the affected fixture. If you can't pinpoint the odor, there's a chance that a drain or vent pipe is damaged. Since it's behind the wall or under the floor, the odor could travel to another part of the house before you detect it.
Suspect a break in the plumbing if you smell sewer gas but don't notice any drains running slowly or any problems with the toilets. The break may have occurred because someone drove a nail into the wall and hit a pipe or because the pipes weren't installed properly in the first place. A plumber can locate the leak by doing a pressure test on your drain system, and once you know where the break is, it's usually easy to fix it.