Donald Rabin had scoured train after train in Chicago for four hours. He had filed a missing item report with police. He had even called every Blue Line stop.

Still, the $22,000 flute Rabin had left on a Chicago Transit Authority train last Friday was nowhere to be found.

So, as a last shot, Rabin, a graduate student at Boston Conservatory at Berklee College of Music who was visiting Chicago, took to his Facebook page.

“FLUTE EMERGENCY,” Rabin, 23, wrote. “My flute was left on the train. … I’m desperate to find it because it is my joy, career, and sole passion in this world. … I just hope that a kind soul is out there with my instrument.”

Against all odds, Rabin got a message back. A homeless man had found the silver and 18-karat-gold flute, but there was a catch: He’d have to accompany him to a pawnshop and pay $550 to retrieve it.

“There was no way that was happening,” Rabin told The Washington Post in an interview late Thursday.

It would take a conscientious pawnshop owner and the help of the Chicago police, but Rabin eventually got back his prized flute, without having to pay the $550.

“I really do empathize with the homeless couple,” Rabin told The Post. “I believe in second chances, and I wanted to give him the benefit of the doubt.”

The treasured instrument was a gift from his late grandmother, who left Rabin part of her inheritance so he could buy his first professional flute.

Last Friday, shortly after arriving at O’Hare International Airport, Rabin boarded a Blue Line train on his way to his rental place in the Wrigleyville neighborhood. As he made himself comfortable, he placed the black leather case with his flute in a crevice between his seat and the wall, making a mental note not to leave it behind, he told The Post.

But when the train got to his stop, Rabin, who struggled with gathering his luggage and laptop before the doors shut, sprinted his way out of the train. Moments later, when the train was no longer on the platform, he realized he had forgotten to grab the one item he vowed not to: his flute.

Panic ensued, he said, but he knew that he did not have much time.

“I realized I needed to take matters into my own hands,” he said.

When his hours of searching and calling stations didn’t pay off, he spent the following days contacting local news organizations and posting his last plea on his Facebook page. “My flute was left on the train,” he wrote on Sunday along his contact information. “The flute is my livelihood and I’m trying every possible thing I can do to get it back.”

By Tuesday, the day he was expected to fly back home to Boston, he doubted he’d ever see his flute again. “There’s no call. Nobody has turned it in. I’m going to be leaving a place for the first time without my instrument,” Rabin said.

Then, as Rabin sat on the plane about to take off, a man commented on his post with a picture of his flute. “Hey Donald … I’m the one who found your flute on the blue line a few days ago,” the message from Mcentee read. In another message, Rabin said, the man explained that he and his wife, who are both homeless, took the instrument to a local pawnshop in exchange for a $500 loan. Rabin could get his flute back once he paid $550 (with $50 more for the interest accrued) to the pawnshop. “If you could help me out with any kind of reward [it] would be great,” the man wrote.

Meanwhile, Gabe Coconate, the owner of West Town Jewelry & Loan, told the Chicago Sun-Times he had already called police on Monday after his wife recognized the flute on a news report. Mcentee returned to his shop a couple of times, Coconate told the paper, but Chicago police advised him to hold on to it.

“I go: ‘Listen man, it’s been all over the news. It’s not your flute,’ ” Coconate told the Sun-Times. Police picked up the flute from the pawnshop on Wednesday, Rabin said. He flew back to Chicago on Thursday to get his instrument back and played “Over the Rainbow” at the police station to say thank you.

Retrieving the flute had little to do with its monetary worth, he said.

“When I play, I always feel this emotion and sense of peace. I know in my heart that that’s my grandmother,” Rabin told The Post. “So today, when I finally got to hold the flute in my hands, I felt like it was my grandmother again.”

Rabin says that although he wishes Mcentee had just given the flute to CTA’s lost-and-found, he hopes the tale of his lost flute can end up helping Mcentee, who said he sleeps on the Blue Line with his wife every night. Mcentee did not immediately respond to a request from The Post as of early Friday.

Mcentee is now raising funds to secure an apartment with his wife, according to his GoFundMe page.

“I gave them $25 for their GoFundMe, and I tried to give them $60 for their hotel that night,” Rabin said. “I told them I would share their GoFundMe. I wanted to help them. I really sympathize with them, too.”