Julián Castro went too far with his crack about 76-year-old Joe Biden’s memory during Thursday’s debate, several of his fellow 2020 Democratic contenders said, with one calling it “not cool,” and “so personal and so unnecessary.”

The former Housing and Urban Development secretary, 44, accused the former veep of forgetting a point he’d made just minutes earlier during a discussion about some candidates’ demands for “Medicare for All,” which Biden opposes.

“Are you forgetting what you said two minutes ago?” an incredulous Castro asked as some audience members gasped.

“Are you forgetting what you said two minutes ago? I can’t believe that you said — two minutes ago — that they had to buy in and now you’re forgetting that. We need a health care system where you’re automatically enrolled,” said Castro, a Texan on his home turf.

Minnesota Sen. Amy Klobuchar, 59, who admonished Castro onstage, later told CNN that Castro’s attack was “not cool,” and “so personal and so unnecessary.” She added: “It feels like something that Donald Trump might tweet.”

But South Bend, Indiana, Mayor Pete Buttigieg hit Castro immediately onstage for his remark.

“This is why presidential debates are becoming unwatchable. This reminds everybody of what they cannot stand about Washington. Scoring points against each other, poking at each other,” he said.

Castro replied: “That’s called the Democratic primary election, Pete. That’s called an election,” and a day later said he had no regrets but denied that he meant the “two-minute” remark as a crack about Biden’s age and memory.

Castro told CNN Friday morning that he would’ve asked the other candidates the same question.

“It didn’t matter that it was Joe Biden. If it had been another candidate that tried to deny what they just said two minutes ago, I would have asked them the same thing,” Castro said.

Sen. Bernie Sanders of Vermont said he was only going to go after Biden’s record.

“I’m not going to go after him personally. That’s not right,” the 78-year-old Sanders said.

But analysts said that questions about candidates’ ages were legitimate, not just for Democrats but for 73-year-old President Trump as well.

“Age is a real issue for Biden, Sanders and Trump. Anyone who doesn’t include all three is showing their bias,” Larry Sabato, head of the University of Virginia’s Center for Politics, told The Post.

“It’s a fact of life. Certain skills deteriorate over time, and there is a greater chance of serious illness and mental decline. It’s perfectly all right for voters to take this into account,” he said.

But, he added, Castro didn’t do himself any favors by asking the questions in such an aggressive manner.

“Castro showed us what can happen when a candidate attacks another one in a cruel and clumsy fashion. Castro is already getting plenty of blowback, and they’ll be plenty more to come,” he said.

“It’s true that Trump launched multiple nasty broadsides in 2016, and got away with it. It doesn’t seem to work on the Democratic side.”

But Biden adviser Anita Dunn ripped Castro later in the spin room right after the debate, saying that his “cheap shot” was “based on a lie.”

“I think Castro, who likes to talk about learning from history, clearly didn’t learn from the first two debates that taking personal cheap shots at Vice President Biden actually doesn’t work out that well for the candidate who throws the shot,” Dunn said, Fox News reported.

“It’s unfortunate that Castro decided to go the route he did.”