Container ships are stacking up again off Southern California’s jammed ports, as a flood of imports and logjams in domestic logistics networks hit operations at the biggest U.S. gateway for seaborne trade.

Thirty-seven container ships were anchored off the adjacent ports of Los Angeles and Long Beach in recent days, according to the Marine Exchange of Southern California, the highest number since February, when 40 ships waited there.

Aboard are hundreds of thousands of boxes stuffed with goods bound for manufacturers and retailers as U.S. businesses hustle to restock inventories and prepare for the holiday shopping season. Just a couple of months ago, the number of container ships at anchor in the two ports, which together handle more than a third of all U.S. seaborne imports, had dwindled to nine. In normal times, the number is one, or none.

Leaders of the two ports say the armada of cargo ships is due to surging volumes and unpredictability in global supply chains caused by the Covid-19 pandemic, and exacerbated by shippers pulling holiday-season imports forward to avoid delays later.

American importers are bringing in cargo earlier “knowing that it probably will take longer to get it into their systems,” said Port of Los Angeles Executive Director Gene Seroka.

The West Coast congestion is one of a number of global bottlenecks as ports juggle strong consumer demand and shortages of workers and equipment caused by pandemic-related health and safety measures. Twice this year dozens of container ships had to wait at anchor in major Chinese ports because of slowdowns in operations after coronavirus outbreaks.

Some shippers have sought alternatives to ocean carriers.

“These challenges have been leading [to] significant delays and additional logistics costs, particularly as we’ve been making more use of airfreight,” Adidas AG Chief Executive Kasper Rorsted said on a recent earnings call.

But airfreight isn’t an option for many shippers because of the expense. Liner companies say in most cases diverting cargo to less congested seaports isn’t possible because they aren’t equipped to handle tens of thousands of containers, many bound for inland destinations thousands of miles away.

Container ships and oil tankers outside the ports of Los Angeles and Long Beach in April. In February, the number of ships awaiting berth at the complex reached 40. In normal circumstances, no more than one might need to stand by.

Photo: lucy nicholson/Reuters

“Sometimes you accept the wait time,” said Nils Haupt, a spokesman for German container line Hapag-Lloyd AG . “The port is too important.”

The Southern California port complex, which has rail links to key Midwestern freight hubs in Chicago, is handling a record amount of cargo.

Last year, the two ports moved a combined record 17 million 20-foot-equivalent units, or TEUs, of containers, despite a Covid-related slump in the first half of 2020, said Mario Cordero, executive director of the Port of Long Beach. This year, the ports are forecast to surpass that and move a combined 19 million TEUs, he said.

The crush of imports is overwhelming Southern California warehouses, driving up rents and making space harder to find. Last month, the two main railroads carrying containers from the ports temporarily restricted shipments from the West Coast into Chicago because boxes were piling up at their Midwestern hubs as containers arrived faster than they could be switched for onward transport.

Containers are stacking up at marine terminals, too, as the record volumes strain truck and rail capacity.  At APM Terminals in Los Angeles, part of the A.P. Moeller-Maersk A/S group, boxes are being stored for an average of nine to 10 days before they move inland, compared with a pre-pandemic average of two to three days, said Tom Boyd, a spokesman for Maersk, which has six container ships at anchor waiting for a berth.

“There’s nobody to blame for this,” Mr. Boyd said. “We don’t have unlimited capacity of ships or railcars or trucks in the supply chain, so what you are seeing is just immense cargo volumes coming in every week and the system has slowed.”

Earlier

In spring 2021, an average of 30 container ships a day were stuck outside the Ports of Los Angeles and Long Beach just waiting to deliver their goods. The backlog was part of a global supply-chain mess spurred by the pandemic that means consumers could see delivery delays for weeks. Photo Composite: Adam Falk/The Wall Street Journal (Video from 4/12/21) The Wall Street Journal Interactive Edition

Write to Paul Berger at Paul.Berger@wsj.com