An American man who was locked up in Cuba for five years for trying to expand its Jewish community’s access to the internet has accused Bernie Sanders of praising the Communist dictatorship when he visited him behind bars, according to a report.

Alan Gross told NPR that the Vermont senator, who visited Cuba as part of a congressional delegation in 2014, told him he didn’t understand why people criticized the country.

“He said, quote: ‘I don’t know what’s so wrong with this country,’ ” said Gross, 70, who is Jewish like the leading Democratic president hopeful.

Sanders’ campaign declined to comment to NPR about the meeting with Gross. Sen. Jon Tester (D-Mont.), who was on the trip, told the outlet that he did not recall the conversation.

A source close to then-Sen. Heidi Heitkamp, a Democrat from North Dakota who was part of the delegation, told NPR she recalled that Sanders seemed to disregard the meeting with the prisoner in which an uncomfortable exchange had occurred.

During a recent interview on CBS’ “60 Minutes,” Sanders said it was “unfair to simply say everything is bad” with the way the late Cuban despot Fidel Castro ruled the country.

“When Fidel Castro came into office, you know what he did? He had a massive literacy program. Is that a bad thing? Even though Fidel Castro did it?” Sanders said on the program in response to a question about remarks he had made in the 1980s claiming Cubans didn’t rise up against the revolutionary leader because of education and health care.

When reminded about the significant number of dissidents imprisoned in Cuba, Sanders said, “We condemn that.”

Sanders, who has spoken favorably about other autocratic regimes in Nicaragua and the former Soviet Union, told “60 Minutes” that he does not consider North Korean despot Kim Jong Un “a good friend.”

“I don’t trade love letters with a murdering dictator,” he said, in a clear reference to President Trump. “Vladimir Putin, not a great friend of mine.”

Gross, who says he opposes Sanders’ campaign for the White House, was arrested in 2009 after completing a US Agency for International Development subcontract.

He said his captors threatened to pull out his fingernails and to hang him.

“The first year of my captivity was akin to sensory deprivation because I saw about 20 minutes of sunlight during the first year,” he told NPR.

He was eventually sprung in exchange for the release of three Cubans convicted of spying.