WASHINGTON — New York election officials are bracing for a mess at the polls because they expect many Bernie Sanders voters will show up who can’t vote.

Only registered Democrats and Republicans are allowed to cast ballots Tuesday in the closed primary, but election officials have been getting an earful from independent voters peeved the deadline to change their party registration was Oct. 9 – long before the presidential election was on their radar.

“I’m going to predict that a lot of Sanders people who come from the ranks of independent voters are not actually registered Democrats and they will cause lines and waits at the poll sites while they attempt to vote affidavit ballots or obtain court orders to vote,” said John Conklin, a spokesman for the state Board of Elections.

Unlike other states, New York allows only registered party members to vote in their respective primaries. So the 5.3 million registered Democrats can vote for Sanders or Hillary Clinton and the 2.6 million Republicans can vote for Donald Trump, John Kasich or Ted Cruz. But nearly 3 million independents and other party members are shut out.

Judges, the NYPD and poll workers are on alert for potential chaos, officials say.

In New York City, election workers have been advised not to argue with insistent independents whose names are not in the poll books.

Instead they’ve increased the supply of affidavit ballots at each polling site to hand out to would-be voters.

Those ballots would only be counted after the election if records show they were cast by registered Democrats or Republicans.

If a voter refuses an affidavit ballot, they can see a judge about granting a court order to allow a vote.

“If there are crowds at poll sites – that’s what we expect, if there are any unruly crowds then we will coordinate with the New York City Police Department,” said Michael Ryan, executive director of the city’s Board of Elections.

“I can tell you I’ve been in and around elections in New York City for over 30 years and this is the first time I’m hearing of people complaining about the voter registration deadlines quite this vociferously,” Ryan said.

Voter data show about a third of the non-major party voters are millennials – a major constituency for Sanders.

Zach Handler, a 29-year-old actor who lives in the East Village, is one of the shut-out independents who is considering showing up at the polls to protest the rules.

He’s a progressive who favors Sanders but didn’t know about the deadline to switch his party affiliation until it had passed.

“As a direct action, I’d love to just go and have the awkward moment with the poll worker and make them explain to me why I can’t vote even though I’m a registered voter and taxpayer,” Handler told The Post.

Protests are planned for noon Thursday at City Hall to rail against New York’s closed primary and last year’s October deadline to change party affiliations.

“Many, many people will be shut out of voting in what very well may be the most important election in a generation in New York state,” said Jeremy Gruber, senior vice president at Open Primaries, a nonpartisan group organizing the New York rally.

“No one should have to join a party to exercise their right to vote,” he added. “We’re a democracy.”