New York City employers are squarely blaming a raging drug epidemic for much of the trouble they have filling jobs in one of the tightest labor markets in a generation.

More local prospective workers are testing positive for substance abuse, or showing up stoned for work, according to industry analysts.

And even as weed is legalized in some places, or viewed as more socially acceptable, it’s not just marijuana’s job-impairing side effects that bother these hiring managers. The abuse of hard drugs, such as cocaine and methamphetamine, has exploded, and further threatens productivity.

Many jobs in New York City now take 60 days or more to fill. Thirty percent of the openings in New York City for registered nurses, bartenders, delivery drivers, program managers and machine operators that are posted on professional job websites go unfilled for 60 days or more, according to the employment portals.

A 2018 report by Quest Diagnostics reveals a 150 percent increase from 2013 to 2017 of methamphetamine positivity rates for workers tested in the wider New York region, which covers New Jersey and Pennsylvania.

Drug abuse rates overall for workers tested in New York state were at 3.5 percent in 2017, compared with 3.2 percent a decade earlier, the Quest data analysis shows.

The drug crisis comes as the local job market is very tight, with the New York City unemployment rate at 4.1 percent.

And the Labor Department said job openings in August topped a record 7 million nationwide — with the number of openings exceeding job seekers by 902,000 — as the national unemployment rate stands at a 49-year low of 3.7 percent.

Analysts believe there is a direct connection between drug-impaired workers and employers’ inability to fill open slots.

“Now that the economic considerations of this are real, it is time for a fresh look at what is happening in this area of drug testing,” said Peter C. Earle, an economist at the American Institute for Economic Research.

Today, some analysts believe as many as 25 percent or more of applicants for some jobs in New York City are failing drug testing, reflecting a broader national pattern. Analysts estimate that tests are conducted by as many as 50 percent of New York City employers.

“It’s a huge issue,” said Earle, adding that though changing attitudes toward marijuana complicate perspectives on that substance, abuse of hard drugs by workers should be a no-no for employers.

“These changing patterns and geographical variations may challenge the ability of employers to anticipate the drug of choice for their workforce, or where to best focus their drug prevention efforts to ensure a safe and healthy work environment,” said Barry Sample, a senior director at Quest Diagnostics.

Substance abuse cuts a wide swath. New York’s hospitality sector is an example.

Andrew Rigie, executive director of the NYC Hospitality Alliance, said some employees can slip up in the high-pressure, alcohol-fueled atmosphere of bars and restaurants.

No-shows at work, or staff turning up on the job strung out or high on pot, are not uncommon in the industry.

“We have people in the business who certainly struggle,” Rigie told The Post.