Some lucky Kentucky residents were able to skip the line and get COVID-19 vaccines — because their local Walgreens had extra doses.

Louisville restaurant owner Andrew Masterson told the Courier-Journal that he was among those immunized, despite not being part of a priority group, after a pal told him Pfizer shots were available at their local Walgreens.

“He called us, and we ran right up,’’ Masterson said of himself and his wife.

“It was pure luck,” added Masterson, whose wife has stage 4 cancer.

A Walgreens rep told the outlet that while the general public wouldn’t normally be offered the vaccine before groups such as frontline healthcare workers and nursing-home residents, the pharmacy-chain giant found itself with expiring leftover doses.

The extra shots were offered to local first-responders, the store’s workers and also residents, many of whom are over age 65, said the spokesman, Phil Caruso.

It was “an isolated situation in which the amount of vaccine doses requested by facilities exceeded the actual need,’’ Caruso told the Courier-Journal.

“These measures were taken to ensure every dose of a limited vaccine supply was used to protect patients and communities.”

It was not clear how many extra doses there were.

Caruso said Walgreens would reach out to those who got the leftover shots to make sure they also receive their second required immunization.

Kentucky Gov. Andy Beshear said Monday that something similar happened at a Walgreens in Lexington last week — and he isn’t happy about it.

The US is still rolling out its limited supply of Pfizer and Moderna vaccines, with health officials saying it will be months before everyone has access to them.

“The reaction wasn’t what it should have been,” Beshear said of how the Kentucky drug stores handled their extra doses.

“Now, do I believe it came from a good place? Yes, because they didn’t want any of it to go to waste,” he said. “But should it have been done differently? Yes.”

The governor said the state, which requires priority groups get vaccinated first, will work “to ensure the right thing happens next time.”

The development came after a Disney worker in California boasted on Facebook on Dec. 20 that she also received the vaccination, even though she is not in any priority group, because of extra doses at the hospital where her husband’s “big deal’’ aunt works.