When you gotta go, don’t count on going at Starbucks.

The caffeine king, with 190 locations in Manhattan alone, has been steadily closing some of its restrooms.

“Starbucks cannot be the public bathroom in the city anymore,” said a source familiar with the company’s New York plans.

The main reason for the closed-door policy is that Starbucks’ own employees have to wait in lines — competing with customers filled with Pumpkin Spice Latte and other trendy drinks — when they take a bathroom break. Or they can cut in line, but that angers customers.

The solution is to convert public bathrooms to employee-only loos.

For example, the Starbucks on 45th Street and Sixth Avenue converted its public john to employees-only this year.

Two others, at Spring Street and at 67th Street and Columbus Avenue, reduced their restrooms from two to one.

“They are not eliminating bathrooms, but feeling the pressure of more people,” the source said.

For out-of-towners, it will be a guessing game.

“If you are a tourist, you will not know which Starbucks has a bathroom,” the source said.

The source said reducing the number of public johns is “not a stated policy” of the Seattle-based company, but it is happening. Efforts to obtain comment from Starbucks headquarters were unsuccessful.

Any food establishment with more than 19 seats is legally required by the city to have a public restroom. The typical Starbucks in Midtown has fewer than 20 seats.

At one store, which closed a public bathroom this year, a worker cited another reason for the change: the cost of having to fix it two or three times a week.

“We closed off the public bathroom because it was just too messy,” the worker said.

Earlier this month, Starbucks — with more than 17,000 outlets in 50 countries — reported strong sales globally and a rise of nearly 29 percent in quarterly profits.