Thousands in the Washington region are flocking to public coronavirus testing sites amid a record surge in cases, with many hoping for negative results before visiting family over the Thanksgiving holiday.

The seven-day average of new cases across Virginia, Maryland and the District notched a high Wednesday for a 15th consecutive day, jumping to 3,830 daily infections. The spike propelled the region’s number of confirmed cases since the start of the pandemic to more than 400,000 infections.

Public health officials are bracing for “substantial community transmission” as the holiday season approaches, said Natalie Talis, population health manager at the Alexandria Health Department. The dire warnings are accompanying an array of recent restrictions on social and economic activity as officials look for ways to blunt the virus’s spread.

The rising demand for coronavirus tests was evident Wednesday at several testing sites, where dozens or, at least at one location, hundreds waited for hours. Lines were short or nonexistent at other locations.

In the District, the number of people tested daily has risen from fewer than 2,000 during the summer to as many as 4,200, said Christopher Geldart, the city’s director of public works.

At the Judiciary Square testing site, hundreds of people wrapped around several city blocks Wednesday, bundled in scarves, blankets and headbands to fend off the cold. Some jogged in place to stay warm.

Many in line said they wanted tests before Thanksgiving and were willing to wait as long as needed to avoid infecting their families. Rachel Rosenfeld, 25, ultimately waited 2½ hours.

“This is the longest wait I’ve ever had. All the other times it’s been 10 minutes or five minutes,” said Rosenfeld, who wanted to get tested before seeing family in Virginia next week. “I assumed this one would be longer because of Thanksgiving, and it definitely turned out to be. But it was worth it.”

Public health officials have cautioned against people gathering with family and friends outside their households for Thanksgiving, saying coronavirus testing can’t protect against all infections. And yet many officials, from Howard County to Alexandria to the District, said the spiking demand for tests appears to be, in part, because of holiday plans.

Officials also said some people are seeking tests because they feared they were exposed to someone with the coronavirus as infection rates rise.

“We’re hearing a lot of people are getting tested in anticipation of air travel or before seeing loved ones, which is concerning to us, because we’re encouraging people to not travel,” Talis said. “We also don’t want [the tests] to give people a false sense of security.”

In Arlington, more than 50 people were lined up at the Arlington Mill walk-up testing site Wednesday before it opened.

Near the front was Allegra Jabo, who said she was saving a spot for her husband and two daughters for precautionary Thanksgiving tests. She tried to get tested Tuesday but said the line wrapped around the building, so she arrived early the next day.

“I decided it would be better to wait one hour at the front of the line than three hours at the back,” she said.

The longer wait at the site is a new phenomenon that didn’t exist even two weeks ago, said Hannah Winant, public affairs manager for Arlington County’s emergency management agency.

Elsewhere in Virginia, officials in Prince William County said the county’s free testing sites have started running out of test kits as quickly as 30 minutes after they open because of the increased demand.

Alison Ansher, who leads the county’s health district, told the Board of County Supervisors on Tuesday that she is unsure whether the demand is from worries about the spike in cases or Thanksgiving travel. But she said it’s too soon to know whether Prince William should ramp up its testing capacity.

“If the trend continues, we’ll certainly look toward providing more testing opportunities,” she said.

Virginia health officials said Wednesday that the state has abundant testing resources and that wait times have not been long, except at some large community testing events. State officials said the average wait for results at state labs is two days, an improvement compared with earlier in the pandemic.

New restrictions went into effect Monday in Virginia that lowered the number of people allowed to gather and imposed new limits on restaurants and businesses. Virginia recorded 2,071 new cases Wednesday, higher than the state’s seven-day average of 1,761 daily infections, and 25 coronavirus-related deaths.

Virginia Gov. Ralph Northam (D) made an emotional plea Wednesday for residents to abide by the new restrictions, choking up as he described seeing images of mobile morgues in other states to handle the bodies of covid-19 victims.

“I’ll tell you what really affected me was seeing mobile morgues outside of hospitals, because there’s no place to put the dead,” Northam said at a news conference, shaking his head and pausing briefly. “We don’t need that to happen in Virginia.”

He said he would tighten restrictions again if caseloads continue to march upward.

In Maryland, the state reported 2,018 new cases Wednesday, with its seven-day average of 1,914 daily cases setting a record for the 15th straight day. It’s the third-highest daily total since the start of the pandemic — with all three coming in the past five days. Maryland also reported 16 coronavirus-related deaths.

The state tightened pandemic-related restrictions Tuesday, for the second time this month, when Gov. Larry Hogan (R) issued an executive order to limit the hours that restaurants can operate and the number of people allowed in retail stores.

Elin Jones, a spokeswoman for the Anne Arundel County Health Department, said health officials decided Tuesday to test only those with appointments because cars were backing up at a drive-through testing operation.

“We are hearing that this is a response to more people having symptoms, media and data reports on the fall surge,” Jones said in an email. She said the turnaround time for test results is two to four days.

Pascal Crosley, who owns Quality First Urgent Care in Burtonsville, Md., and is running testing at two fire stations in Howard County, said demand has doubled or tripled since early last week, citing concern about the winter surge and people seeing family over the holidays.

He estimated up to 95 percent of people who come in are ­asymptomatic and concerned about exposure or taking holiday precautions — a change from the spring, when most were essential workers with symptoms.

“Demand has outstripped supply when it comes to testing,” Crosley said Wednesday at a fire station in Savage, Md. “And we haven’t really even hit flu season yet.”

Several jurisdictions were making adjustments to accommodate the increasing demand.

Montgomery County requested more test kits from private laboratories and plans to provide more opportunities for being tested in the evenings and over weekends, county Health Officer Travis Gayles said.

The District on Wednesday recorded 156 new cases, near its seven-day average of 155 daily cases. That average number has doubled since the end of October, but it is below the peak of 194, set May 6. D.C. recorded five coronavirus-related deaths Wednesday — the most in a single day since June 16.

Mayor Muriel E. Bowser (D), who said Wednesday that she would impose new restrictions “soon” to combat the rise in cases, announced that next week the city will begin to offer tests for five hours each weekday afternoon in a parking garage at Nationals Park. The city will also extend hours at its testing sites.

The city has paid for tests administered at its public sites. Beginning Monday, those with health insurance will be asked to provide insurance information when registering online for a test so insurers can bear some of the cost.

Bowser said that no one will be charged a co-pay and that the city will continue to pay the cost for any resident without insurance.

“It is going to help us with the sustainability of our testing system,” Bowser said. “We can make better use of District resources. Insurance companies should be paying for the test.”

Geldart said that the city has enough test kits to cover the rising demand and that turnaround times have stayed between three and five days for those tested at public sites.

The region’s 4,245 new daily cases Wednesday lifted the total of confirmed infections in Virginia, Maryland and the District since the start of the pandemic to 400,121.

Public health experts were consistent in their pleas: If traveling, reconsider and stay home. Neil J. Sehgal, a health policy professor at the University of Maryland School of Public Health, said he was looking at staying home this way: “It’s worth it to me this year so that I can have Thanksgiving next year.”

“I’m imploring friends to cancel their travel plans now,” he said. “Even if you’re going to visit someone who has been isolating, it’s the journey, it’s all of the social friction that you create getting there that creates the risk.”

Antonio Olivo, Ovetta Wiggins, Rebecca Tan, Erin Cox and Laura Vozzella contributed to this report.