Dockworkers are preparing to strike at midnight across dozens of ports from Maine to Texas, threatening to block the movement of a swath of U.S. trade and rattle the American economy five weeks ahead of the presidential election.

Trade groups representing hundreds of retailers and manufacturers from Walmart and Target to Caterpillar and General Motors have appealed to the Biden administration to intervene, warning a shutdown could hobble businesses and trigger renewed inflation during the busy holiday shopping season.

“The effects of the strike have already begun,” said Tim Ryan , owner of Square 1 Farms, a Sunrise, Fla.-based importer that sells asparagus to supermarkets such as Walmart, Kroger and Wegmans.

Ryan will fly in 150,000 pounds of asparagus from Peru this week that would usually arrive by ocean at Florida’s Port of Miami, to avoid the risk of the vegetables getting stuck at sea and rotting. The more expensive air rates will quadruple Ryan’s transportation costs and add about 50 cents a pound to the prices he charges stores.

“Either supermarkets elect to absorb that cost or they will pass it on,” he said.

JP Morgan equity analysts estimate a ports strike would cost the U.S. economy between $3.8 billion and $4.5 billion a day, some of which would be recovered once normal operations resume.

The White House so far has declined to intervene. Biden administration officials, including the secretaries of Transportation and Labor, met with the leaders of a group representing port employers on Friday to urge them to come to the bargaining table. A White House official said the administration had “been in touch” with the union during the week.

A person familiar with the administration efforts said the White House believes the country’s supply chains are resilient and that the economy could weather a short strike of up to about a week.

The International Longshoremen’s Association, which represents 45,000 dockworkers at East Coast and Gulf Coast ports, is threatening to shut down some of the country’s main gateways for imports of food, vehicles, heavy machinery, construction materials, chemicals, furniture, clothes and toys.

In the first seven months of this year, the ports handled 74% of the country’s seaborne wine imports, 75% of its banana imports, and 89% of imports of salt used in chemical manufacturing, according to U.S. Census Bureau figures reviewed by Jason Miller , a professor of supply-chain management at Michigan State University.

The Port of New York and New Jersey, the third-busiest container seaport in the country, handled the equivalent of more than 420,000 imported containers in July. That same month, the Port of Baltimore, the country’s largest gateway for automobiles and light trucks, processed more than 34,000 new vehicles.

Port employers have been lurching toward a strike for months. The union in June called off scheduled contract talks as major ocean shipping lines, mostly based in Europe and Asia, reported skyrocketing profits.

Ocean carrier earnings surged this year after Houthi rebel attacks on ships in the Red Sea forced carriers to take longer routes around the region, eating up capacity and driving up freight rates . Denmark-based shipping giant A.P. Moller-Maersk in June projected a $3 billion improvement in free cash flow for the year over a prior forecast.

The ILA’s leader, Harold Daggett , says workers deserve a share of those profits as well as the hundreds of billions of dollars ocean shipping companies made during the Covid-19 pandemic, when demand for space on containerships pushed freight rates to record highs.

According to a person familiar with the matter, Daggett has said he won’t negotiate until employers agree to a 77% increase in wages over six years. Talks then would cover thorny subjects such as the use of automation.

Port employers and ocean carriers, represented by the United States Maritime Alliance, have offered an almost 40% wage increase, an offer that Daggett last week called “insulting.”

The ILA says a strike won’t affect military cargoes or cruise ship services.

Shipping and energy industry officials say they expect exports of oil and liquefied natural gas at Gulf Coast ports to be unaffected because the ILA has little or no involvement in those operations. The union’s bulk-ship operations, which handle industrial commodities such as coal and grain, are covered under a separate contract. Most containership movements at the two coasts are expected to stop.

Matt Carstens , chief executive of Iowa-based farmer cooperative Landus, said because of weak demand from China many grain farmers are relying more on East Coast and Gulf Coast ports to get their product to places such as India and Europe. He warned that a strike could also slow imports of fertilizer from Morocco and parts of Europe that farmers need to replenish fields this fall.

Car buyers could also be affected. Nationwide inventories of new vehicles have returned to near prepandemic levels, according to Cox Automotive. But K. Venkatesh Prasad , a senior vice president of research at the Center for Automotive Research, said prolonged delays could cause auto distributors to run short of parts needed to customize vehicles.

Because of strike fears, many retailers rushed in items early this year and rerouted goods to West Coast ports , pushing import volumes to the highest levels since the peak of the Covid-19 pandemic.

Derek Schmidt , CEO of furniture importer Flexsteel Industries , said his East Coast warehouse is well stocked. “We’re most concerned about the impact of a strike on container rates,” he said.

Some ocean shipping companies have warned of surcharges in the event of a strike of between $1,500 and $3,000 a container, according to JP Morgan analysts. They say container rates could rise by several thousand dollars a box in the case of a five-day strike.

Congestion from a strike would also ripple across global supply chains. It would tie up ships and containers that are needed for exports from Europe and Asia.

Containership operators have few options if ports close. Unionized dockworkers at U.S. West Coast ports won’t work diverted ships. Alternate ports in Canada and Mexico are too small to cope with the volumes of cargo that ILA workers handle.

Nils Haupt , a spokesman for German shipping line Hapag-Lloyd , says that if the carrier sends extra cargo volumes to West Coast ports it would clog up those gateways causing congestion similar to the containership backups seen during Covid.

Many East Coast and Gulf Coast ports extended their operating hours this past week so that importers could clear cargo from the docks ahead of an expected shutdown at 12:01 a.m. ET tonight. Freight railroads in recent days stopped taking hazardous, high-value and refrigerated cargoes destined for exports.

Dockworkers are among the best-paid blue collar workers in America. Neither the ILA nor the port employer group, USMX, disclose comprehensive data on wages, but dockworkers’ base hourly rate of $39 commonly translates into a six-figure annual salary because of work rules and overtime requirements.

In the financial year that ended in 2020, more than half of 3,726 dockworkers at the Port of New York and New Jersey earned over $150,000, according to a report by the port’s regulator. Some 665 dockworkers that year earned more than $250,000.

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