Photo: Lea Suzuki / The Chronicle

The average gas price in California has hovered around $4 per gallon for most of the week. San Francisco’s figures are slightly higher, reaching $4.09 on Friday. This is the priciest gas in five years, according to the tracking website GasBuddy, and it comes just a month before Memorial Day, when the season of long car trips begins. Prices in California are more than a dollar per gallon above the national average.

Here are questions and answers about the pain at the pump.

Q: Why are gas prices so high?

A: Issues at refineries in California, including the Phillips 66 in Los Angeles County, Valero in Benicia and Chevron in Richmond, along with planned maintenance at others, have constricted supply in the state, which in turn raised prices, according to GasBuddy senior petroleum analyst Dan McTeague. California has strict environmental rules for gas, which makes it difficult to import fuel when its refineries have production glitches.

“The unique nature of gasoline in the state makes replacing it challenging in an environment where there’s a real pressure, a real tightening of supply,” McTeague said.

He estimates that 5% to 8% of California’s total gasoline production is offline because of the refinery issues, and the state is about 2 million barrels of gas short.

Another problem has stemmed from flooding in the Midwest, according to AAA Northern California spokesman Michael Blasky. That has made it more difficult for California to get ethanol, which refineries mix in to make California’s blend of gas.

Representatives of the Valero refinery in Benicia, the Chevron refinery in Richmond and the Phillips 66 refinery in Los Angeles County did not respond to requests for comment.

Q: How long will prices stay above $4 per gallon?

A: It’s hard to pinpoint when gas prices will come back down, according to Severin Borenstein, faculty director of the Energy Institute at UC Berkeley’s Haas School of Business.

“It depends on how fast these refineries that had problems will be able to come back online and resume production,” he said.

“Right now we’re having this spike and we’re about 60 cents above where you would normally expect us to be, but that does happen because when refineries go down you do get shortages.”

Q: Will this be an ongoing issue?

A: Even without the spike in prices from the refinery problems, gas prices were higher than they should have been, according to Borenstein.

Before a 2015 fire at a major refinery in Torrance (Los Angeles County), price spikes after refinery issues were brief, but since then, prices have stayed considerably higher than would be expected, according to Borenstein.

“In 2019, they’ve averaged about 28 cents higher than you would expect them to be, adjusting for taxes, cap and trade and the low carbon fuel standard,” Borenstein said, referring in part to California environmental policies.

A group of state lawmakers asked the state attorney general’s office to investigate the “mystery surcharge,” because in four years, it’s added up to about an additional $20 billion for consumers, Borenstein said.

Borenstein said gas price spikes will likely recur whenever California refineries run into problems.

“Refineries don’t have much of an incentive to invest, because California keeps saying that we are going to reduce our use of gasoline,” he said.

Sophia Kunthara is a San Francisco Chronicle staff writer. Email: sophia.kunthara@sfchronicle.com Twitter: @SophiaKunthara