The spill -- described as one of the biggest in recent memory -- began Monday afternoon, when the top of a sewer pipe collapsed, sending debris into the pipe and causing overflow.
Repair crews managed to stop the leak by evening but the pipe split again on Tuesday, sending sewage into the Los Angeles River which carried it into the Pacific.
Officials ordered all beaches in the Long Beach area and a portion of Seal Beach shut down pending testing of the waters.
Nelson Kerr, of the Long Beach city health department, told AFP that swimming in those areas was expected to be off-limits until at least Thursday.
Long Beach is home to the second-busiest port in the US after Los Angeles.
"This is the biggest spill we've had in recent memory," Kerr said, adding that the pipe that broke is thought to have been damaged during construction in the area.
Tonya Durrell, spokeswoman for the Los Angeles public works department, said the spill was stopped by Tuesday afternoon.
"This is an isolated event tied to an aging sewer built in the 1920s," Durrell said. "The sewer was scheduled for repair and failed before we could do the repairs."
Kerr said the rupture led to 3,000 gallons gallons of sewage flowing out per minute.
Several resident living in the area of the spill reported dirty water rushing up through pipes in their homes and a heavy stench.