Get the latest from TODAY
Shepard, 43, shared the story while interviewing his pal, "Will & Grace" star Sean Hayes, during the most recent episode of his "Armchair Expert" podcast.
In November 2017, NBC announced Shepard would guest-star on the beloved sitcom, but the role never came to be, Shepard explained, because he was "canned."
"I'm fine with it now. It was an interesting feeling to get fired. The only thing I cared about is that you and I were involved," he told Hayes. "Had it been any other thing with a bunch of strangers, I would have been like, 'Oh, whatever. I was at a table read for 45 minutes and then I got fired. Who gives a s---'?"
"I think maybe that was the only element that I was like, 'Well, that's kind of embarrassing. These are people that I know — and then, I got canned,'" he added.
Hayes, 48, seemed mortified that the show's producers gave his pal the pink slip, admitting he "almost blocked it out" because it was so "horrible."
Shepard revealed he was originally cast to play Jackson Boudreaux, a lusty baker who beds both Will and Grace. The role eventually went to "Parks and Recreation" alum Nick Offerman, who's married to "Will & Grace" star Megan Mullally.
To add to Shepard's frustration, he's not exactly sure why he was fired.
"It could be as simple as I was terrible at the table read, and that's fine," he told Hayes. "But that's the only time in being friends for 12 years where I was like, 'Now I feel like there's something awkward between us.'"
Of course, the pair are still as close —and as silly — as ever. In fact, Shepard teased the interview by sharing a gallery of adorable pics of him and Hayes together.
"My dear friend @seanhayes and I have a two hour giggle/love fest, " he captioned it. "If Sean can't brighten your day, go to the doctor immediately and tell them you're dead."