The city moved to fire an employee for missing about 18 months of work, even though he had the best excuse of all time — he was dead.

Bureaucrats at the Human Resources Administration filed charges against Medicaid-eligibility specialist Geoffrey Toliver accusing him of going AWOL — even though his death by cancer was reported in an online obituary.

An administrative-law judge then agreed to his firing, noting Toliver didn’t show up at his hearing.

Toliver died at age 65 on Dec. 8, 2014. His friends described the father of three as a dedicated worker.

“How do you fire a man who is already dead? He deserves better. The agency itself should have known,” said Ted Willbright, who added that he considered Toliver as a brother.

“Some people he worked with were very supportive, so how did HRA the organization not know? He’s dead, and they’re saying he abandoned his job. He didn’t abandon his job, his job abandoned him. He was a good man. Truly, truly a good man.”

HRA officials said they sought to remove Toliver from his $38,000-a-year job after they couldn’t reach him for well over a year.

They marked the start of his absence as Nov. 12, 2013, and said calls and certified letters mailed to his home were never answered.

“We did everything we could to contact him and his family,” said HRA spokesman David Neustadt. “This employee was not paid when he wasn’t working, but we left his job open in case he recovered.”

He said that now that the agency knows of his “unfortunate death,” it would take no further action.

Family members were surprised to hear city officials claim they hadn’t been in touch with Toliver.

“It is my understanding that . . . his employer was fully aware that he was not able to come back to work,” Toliver’s brother Anthony told The Post.

“It is my understanding that my brother’s family spoke directly to his supervisor during his long hospitalization and informed them of his death.”

An online obit said Toliver was born in Harlem as the second of eight children.

“He was very well liked by his colleagues,” it said.

Additional reporting by Jennifer Bain