October 21, 2022 | 8:19pm

Matthew Perry praised Jennifer Aniston for being a good friend amidst his sobriety struggles.

The actor, who recently revealed he “nearly” died from heavy drug use, said his “Friends” co-star confronted him about his scary drug and alcohol use at the height of his career.

In a trailer for his interview with Diane Sawyer — which airs on Oct. 28 — Aniston apparently told Perry, “We know you’re drinking.”

“Imagine how scary a moment that was,” the 53-year-old told Sawyer, adding that “she was the one that reached out the most. I’m really grateful to her for that.”

In the same interview, the “Fools Rush In” star confirmed that he was taking “55 Vicodin a day,” in addition to “Methadone, Xanax” and “a full quart of vodka.”

Perry “nearly died” from his rampant drug use.
Noam Galai

The rampant drug abuse almost killed the actor at the age of 49 when his colon burst from opioid overuse.

At the time, Perry claimed he suffered a “gastrointestinal perforation,”but in reality, he spent five months in the hospital — including two weeks in a coma — and had to use a colostomy bag for nine months after doctors told him he had “a 2 percent chance to live.”

“I was put on a thing called an ECMO machine, which does all the breathing for your heart and your lungs. And that’s called a Hail Mary. No one survives that,” hetold People in a separate interview.

After having to wear the colostomy bag — an external bag for feces to be stored — for nearly a year, the actor decided to get sober and find a therapist.

“It was pretty hellish having one because they break all the time,” he added to the outlet.

Aniston told Perry she knew he was drinking at the peak of his addiction.
Getty Images

“My therapist said, ‘The next time you think about taking OxyContin, just think about having a colostomy bag for the rest of your life,’” Perry continued. “And a little window opened, and I crawled through it, and I no longer want OxyContin.”

Perry, who is now sober, candidly describes his long-fought battle with addiction in his new memoir, “Friends, Lovers and the Big Terrible Thing,” which is out Nov. 1.