The natural gas pipeline in the United States is vast, sprawling across 2.5 million miles in a complex pressurized system that delivers a quarter of the energy consumed nationwide, according to the American Gas Association. Many of the pipes are old, and utilities are in various stages of replacing them to improve safety.

There have been more than 300 fatalities and 1,200 injuries caused by natural gas pipeline incidents in the last 20 years, according to data from the Pipeline and Hazardous Materials Safety Administration, the federal agency responsible for overseeing the industry. As residents recover from Thursday’s stunning explosions in Lawrence, Mass., many wonder what they can do to protect themselves.

A series of fiery natural gas explosions three towns north of Boston killed a teenager, injured at least 25 others and left dozens of homes in smoldering ruins. The cause is under investigation by the National Transportation Safety Board, but the Massachusetts Emergency Management Agency said the fires may have resulted from gas lines that had become over-pressurized.

Following fatal gas pipeline incidents, the Department of Transportation in 2011 called on the industry to replace aging pipelines, particularly those made of cast and wrought iron and bare steel that pose the highest risk.

More than 177 million people nationwide use natural gas in their homes and businesses to provide heat, cook and dry clothes, according to the American Gas Association. Columbia Gas — the company whose pipelines exploded Thursday — and its parent company NiSource serve 3.4 million natural gas customers across seven Eastern states.

HOW IS NATURAL GAS DISTRIBUTED?

Natural gas is a fossil fuel found deep beneath the earth’s surface that’s mostly made up of methane. It is extracted from the ground and distributed in pipelines that span 2.5 million miles nationwide.

The gas is delivered to customers initially through high-pressure pipelines and it goes through a process to reduce its pressure before entering smaller pipelines and eventually homes and businesses.

“In some places, we have 100-year-old gas lines coming up to people’s houses,” said Bob Ackley, owner of Gas Safety, Inc., a Massachusetts-based company.

WHEN HAVE THERE BEEN SIMILAR EXPLOSIONS?

In February, gas-related fires in Dallas killed a 12-year-old girl, destroyed three residences and injured others. A review by the National Transportation Safety Board later found that several sections of pipe near the incident site failed pressure tests.

A gas explosion in 2014 killed eight people in New York City, and the utility Consolidated Edison later agreed to pay $153 million to settle charges that it violated safety regulations.

In 2011, five people were killed by a natural gas explosion in Allentown, Pennsylvania, and regulators called the utility’s safety record “downright alarming.”

Eight people were killed and 38 homes were destroyed in San Bruno, Calif. in 2010 when a Pacific Gas and Electric gas pipeline exploded.

WHAT CAN UTILITIES DO TO IMPROVE SAFETY?

Utilities nationwide are continually replacing older pipelines made of cast iron or certain types of steel with newer steel or plastic pipes, according to the American Gas Association. Many, including NiSource, accelerated those efforts after the deadly San Bruno incident, said Charles Fishman, an analyst with Morningstar Research Services who covers NiSource and other utilities.

“There was a real tragedy, and I think that woke people up across the country,” Fishman said. “The whole industry said wait a second here, we’ve got all these old pipelines, there’s a lot of disasters waiting to happen.”

NiSource was spending $80 million to $120 million annually in Massachusetts to modernize its infrastructure, spending the vast majority on replacing aging gas pipelines, Fishman said. Those efforts are likely to accelerate, but “you can’t tear up every street in the downtown at the same time…and it would dramatically increase the cost to do it really, really quick,” he added.

After the deadly New York gas explosion in 2014, Con Ed set in motion a fleet of trucks that drives around the streets of New York City with leak detection equipment, passing each customer location at least once a month. The company also began a bilingual campaign to inform customers they should call whenever they suspect a gas leak.

Incidents have also occurred when gas lines were damaged during excavation, and some utilities have installed above-ground markers to indicate the location of buried gas lines, according to the American Gas Association.

WHAT CAN CONSUMERS DO TO STAY SAFE?

If people think they smell gas in their homes, experts say they should leave the house or building immediately and call 911. They should not light a match, make a cell phone call or turn on lights or appliances since that can cause a spark.

To be proactive, homeowners also can call their utilities or fire departments to request to have their gas lines checked for leaks and to learn where the pipelines are in their homes.

“They can request a safety check at any time,” Ackley said.