Blackouts, gasoline spikes, and concerns about heating the nation this winter are revealing deep-seated flaws in the nation's energy infrastructure - a system that has become so fragile that power lines sagging on a tree in Ohio can be part of a chain of events helping send millions of people back to the 19th century.

To update and expand this complex system of pipes and wires will cost hundreds of billions of dollars, much of which will come from consumers' pockets. The spending will have to come relatively soon, since energy links everything from cellphones to the ability to keep jobs in the country. "We don't just need reliable energy, but a reliable energy infrastructure," says Frank Graves, a principal with the Brattle Group, a leading energy consultant.

In the past, reliability was often taken for granted. For example, the electrical transmission grid usually had 30 to 40 percent reserve capability, so that on sweltering days, utilities could meet soaring demand. At times, so much gasoline sloshed around that price wars broke out.

But now, major changes have made it more difficult to maintain and upgrade the system. Take oil markets. Energy companies now operate on a "just in time" inventory system. This reduces the cost of buying and storing crude oil. But it has also meant that in recent years, inventories of everything from home heating oil to gasoline have been historically low.

At the same time, the number of refineries has shrunk from 300 to 150 as the industry has consolidated. Total capacity is 17 million barrels per day, but US consumption is 19 to 20 million barrels per day.

The difference is made up by imports, which are especially necessary since no new US refineries have been built in more than 25 years. "A lot of it is NIMBY [not in my backyard]," says Bob Slaughter, president of the National Petroleum Refiners Association. "There have been plans for new refineries, but they have been blocked."

One of those was a proposal five years ago to restart a shuttered refinery in Santa Fe Springs, Calif., a suburb of Los Angeles. A company that included the Rev. Pat Robertson as an investor hoped the restart would not include requirements about installing the best available technology to limit emissions. But environmental groups challenged that premise. Faced with the prospect of much higher costs, the company abandoned the effort 18 months ago after spending about $75 million.

"It was a classic clash of the values of the federal Clean Air Act and the need for refined gasoline in California," says Fred Latham, the city manager. "Although the case was never litigated, just the existence of the lawsuit was a significant factor."

Another major change has been the way local groups have learned to use the Coastal Zone Management Act, a federal law designed to protect and provide for sound development of the nation's coastal areas. Under federal authority, states develop their own plans and implement them. But this has also led to significant and costly delays of infrastructure projects.

That's what's happened with the Millennium Pipeline, a proposal to bring Canadian natural gas from Lake Erie to the New York City area. The lead developer of the proposed $684 million project, Columbia Gas Transmission, would like to transport the gas under the Hudson River. "It's our contention that the route is the only viable way to get to the Con Ed system in Mt. Vernon," says Karl Brack, a company spokesman.

But David Gordon, a senior attorney for Riverkeeper, an environmental group, says the proposed route would "damage the river and environment in Westchester County." Instead, he says a much better option would be to follow the New York State Thruway. "I don't think they have thought about it," he says.

So far, the pipeline is four years behind schedule. Columbia estimates that if it had been operating last year, it could have delivered gas at 50 percent less cost than Con Ed's other options. "It would have saved consumers $125 million in the month of January alone," says Mr. Brack.

The Commerce Department will decide whether the company can go ahead by late October.

There have been similar battles over electric transmission lines. This week, the Electric Power Research Institute (EPRI) said the utility industry would need to invest $100 billion to bring the electrical system into the 21st century. "We have been under-investing," says Mark Gabriel, a vice president of EPRI. "Ultimately, most of this money will come from the ratepayers."

Consumer groups say they will battle this effort. "Where is this savings promised to consumers?" asks Tyson Slocum, research director of Public Citizen's energy program. "Deregulation was sold to consumers as a promise of improved reliability but it's more expensive, not cheaper."