First, you need to determine if it is local waste produced in your home that can't get out due to a blockage in the main line leaving your home, or if it is waste from the sewer system coming back in (called a backflow).
A blockage can occur if a portion of the line has broken, but generally a blockage is caused by roots that have grown into the line, or by something flushed down a toilet that has lodged in the drain pipe.
When this happens, you will see evidence of your basement drain backing up as the lowest point in the system (generally the basement drain overflows) is where the evidence is visible.
Chemical products may work to open the drain, but running a snake through the line is generally necessary. In the case of roots of invading the basement drain line, a power snake with sharp cutting blades must be used to cut through the roots.
With your own local waste backing up it's one thing, but when nasty, contaminated waste from hundreds of neighbors starts pouring into your home, it becomes a whole different issue.
In this case, usually due to high levels of rainfall temporarily raising the water overall table, the system will be overwhelmed. If the lowest drain in your basement (or other shower drain or toilet) is lower than this temporarily raised water level, you will find your basement drain backing up. In some cases the pressure created by the raised water level is so great that water raw sewage will be spewing several feet into the room from basement drains.
There is only one way to prevent this particular condition of your basement drain backing up; the installation of a gate to keep the unwanted reverse flow out. Some of these gates are manual and must be manually inserted or manually turned closed.
The best are automated solutions called "Backwater Valves" or "Backflow Preventers"
A Backwater Valve automatically senses a reverse flow (water flowing the wrong direction and back into your home) in your main line and completely closes it off from the sewer system outside. This prevents your basement drain backing up.
A Mainline brand 4963 Backwater Valve installed in the main line below your basement floor is one of the most economical and effective ways that you can prevent your basement drain from backing up.
If I've heard it once, I've heard it a thousand times, "I just had my basement drain overflow, and naturally I was I was . . . at work . . . asleep . . . out of town . . . on vacation. In these cases, the fact that a backwater valve works automatically is worth the associated costs of the valve and installation. As many know, what's as stake is thousands of dollars of damage to the basement living space, not to mention the health hazards caused by the bacteria in the raw sewage produced by hundreds or even thousands of your neighbors.
Some people simply insert a plug into their basement drain in an attempt to stop a basement drain backup, but in a case where groundwater comes in when there is not a mainline backup, the end result is also flooding. Additionally, the force of incoming water can simply push these plugs up and out of the way leaving you unprotected. A good automated backflow valve is the best solution to avoiding a basement drain overflow that lets water in the basement.
The single biggest advantage of the Mainline brand Backwater valve is that it uses a patented normally open design. When properly installed with a required minimum slope of 2% (or more), water and effluent leaving the dwelling works to continuously self-clean the gate, keeping it free and ready to seal when you need it most. There are hundreds of cheap normally closed valves on the market that are destined to fail as debris accumulates at the sealing point. The patented Mainline brand is the single brand backwater valve available with a self-cleaning normally open design.