On the surface, former “Real Housewives of Orange County” star Lauri Peterson appears to be living a carefree life since exiting the show in 2008. Scroll through her Instagram feed and you’ll see photos of the statuesque blonde posing with her husband, George, and doting on her granddaughter.

But all this is belied by the fact that her 30-year-old son, Josh Waring, has spent the past two years in jail on attempted murder charges.

So how did a boy from a gated community in Coto de Caza, Calif., — where the median listing price for a home is $1.4 million — end up behind bars, accused of a serious crime?

“There’s no mystery to the fact that I’ve had problems with drugs,” Josh told us by phone from the Intake/Release Center in Orange County. “The police do know who I am in Costa Mesa.”

Four years before cameras began filming for the Bravo show, Josh, then 12 years old, began drinking alcohol and smoking marijuana, he recently told the Los Angeles Times. When Lauri joined the cast of “The Real Housewives of Orange County” in 2006, Josh’s struggle with the law was such an issue that “Are the police involved?” was her tagline during the show’s opening credits.

At 16, he was charged with felony assault after fighting with his teacher, who thought he had drugs on him (the incident occurred off-camera). “The teacher grabbed Josh and there was a scuffle,” Lauri said on the show at the time. “He’s in juvenile hall.”

“They’re making sure that he’s getting the medications he needs, something that he’s resisted doing for the past several years which has probably led up to all this trouble,” Lauri said in an episode filmed shortly after his arrest. “Josh has very, very high ADHD. Without medications, he has no impulse control at all.”

Lauri, now 57, revealed on the show that he sought treatment between Seasons 1 and 2 at a facility about two hours away from their home. He later described the arrangement to a friend on the show as being forced to attend a “state-run boarding school” after violating his probation.

For the show’s second season, Lauri’s storyline focused primarily on her budding relationship with now-husband George Peterson. But while Lauri’s life seemed to be coming together, Josh’s continued to fall apart. In 2008, he was arrested for possession of heroin along with three counts of possession of a controlled substance with intent to sell, three counts of unauthorized possession of a hypodermic needle or syringe, being under the influence of a controlled substance, false report of criminal offense, and possessing a controlled substance without a prescription.

She quit “RHOC” soon after to focus on her family. In her final episode of the series, Lauri revealed that Josh was sentenced to eight months in jail.

“Josh is in custody right now,” Lauri told the camera through tears. “When I heard of Josh’s arrest, I was confused, humiliated, embarrassed, but more than anything, I’m scared. Scared for Josh. It’s awful. I wouldn’t want to wish what I’m feeling on any parent. It’s devastating. Josh got picked on in jail. He got beaten up. Had to go into the hospital with stitches in his head. It was brutal.”

Josh has been in and out of jail ever since, with Orange County Superior Court records showing his involvement in 30 cases, ranging from traffic offenses to felony drug charges.

Between prison stints, Josh became involved with a woman named Hannah Kiefer, whom, according to court records, he later married on Feb. 25, 2011. Just seven months later, Hannah filed to annul their marriage and requested a restraining order. The ill-fated couple soon made up and welcomed a daughter, Kennady Kaydence, in 2012. But despite becoming parents, they couldn’t overcome their combined substance abuse issues and bounced in and out of jails. In 2015, Lauri and George legally adopted Kennady. A year later, Josh would be arrested for attempted murder.

“Josh gets arrested frequently and … if he is under the influence of drugs and if he’s using drugs at the time, I’m never going to help him out legally,” Lauri told Page Six in an exclusive new interview. “However, [adopting Josh’s daughter] has been life-altering, it has changed our whole entire lives. My contribution to Josh has always been I will always get you rehabs and do whatever I can do to help you medically beat this addiction and I will raise your daughter.”

As a result, Josh has acted pro se — on his own behalf — in the attempted murder case.

On June 20, 2016, Costa Mesa police responded to a call that a man had been shot at a home around 2:30 a.m., the Los Angeles Times reported. Responding officers allege that Josh fled the scene in a stolen 2011 BMW X3 SUV, but eventually surrendered to them after crashing the car and running into a business to escape.

Lauri’s version of events differs from the police account. She claims Josh was at the house earlier in the day to pick up a female friend who was getting kicked out of the known “drug crush pad” that “was being overrun by 30 to 40 drug addicts.”

“Josh pulled up to [the residence] and the girl started coming out and at the same time a large man also came out with her and they were fighting,” Lauri, who was not present during the incident, recalled. “The man took this girl’s belongings and threw them out into the street. And so then he went and approached the car Josh was driving and he called Josh by name and he said, ‘Get out, you little p—y, and fight me.’ Josh didn’t even know who he was and had no interest in fighting him.”

Josh then drove his vehicle “about 10 to 15 feet away” to avoid the man, which angered him, Lauri said. Josh then left the premises without his female friend to avoid confrontation but returned later that night. During Josh’s time at the house that night, a man in a blue car fired shots that left another man, Daniel Lopez, wounded.

When police arrived at the scene, the man who tried to fight Josh earlier in the day told officers Josh was responsible for the crime, but Lauri and Josh later told us that they believe Bryan Goldstein, who had been working as a police informant, was the actual shooter.

Goldstein, 32, is a known drug dealer, according to Josh, Lauri and local outlets. He has a lengthy rap sheet in Orange County and, according to OC Weekly, has only received minor consequences. His public defender did not get back to us for this story.

He was also at an Anaheim hotel room where a murder took place just 23 days after the incident involving Josh. Police found that the same type of gun was used in both cases.

Goldstein exonerated himself in Josh’s case after being coaxed by Costa Mesa police to nail Josh, OC Weekly reports. The outlet, which dubbed Goldstein a “cop-protected Orange County snitch,” also claims Goldstein has worked as an informant for at least 14 years. The Los Angeles Times also reported on his involvement in the crime.

Josh has maintained his innocence “from day one,” Lauri told us. She insisted that even if he wanted to help the cops out, he “can’t rat somebody out” because he doesn’t know all the information.

“My take from it was the police just got frustrated because Josh wouldn’t talk … there’s probably a situation where he doesn’t know all of the facts. The other case is if we knew [who fired the shots], he wouldn’t do that anyway. What Josh has told me from day one is that ‘I didn’t do it. The [gunshot residue report] is going to exonerate me,’” she explained.

Lauri also feels that the victim’s statement will help absolve Josh of any involvement in the crime.

“The victim himself said the only shots came from the blue car,” Lauri said. “Not the white car [which Josh was driving]. He didn’t even mention a white car until the police introduced that to him. The victim never once said Josh’s name. But the police said, ‘Now Josh Waring was there and he was in the little car, right?’ And he’s like, ‘I don’t even know what you’re talking about. I got shot from a blue car.’”

Josh claims that victim himself told police to “stop trying to put words in my mouth” when they suggested him as the assailant.

“Within 10 minutes of me being in cuffs, they had done [the gunshot residue report],” he said. “They tested my hands. They tested my shirt. They tested my pants. They tested my face. My hair. Every surface on me, they ran [the gunshot residue report]. I just knew that that would come back and I wouldn’t have any gunshot residue on me.”

“I know how this works vaguely, so I felt that [the gunshot residue report] was going to be what was going to get me off. I told my public defender, ‘Bryan Goldstein’s [gunshot residue report], it’s going to show you that he did fire a gun,’” Josh explained.

A police report was unavailable due to the state’s policy, per a Costa Mesa police records clerk. The detective assigned to the case could not comment since the investigation is still open.

Six months later, Josh inquired about the results of Goldstein’s gunshot residue report only to be told he was never tested.

“But the victim told [police] the shots came from [Goldstein]! How can you justify that? So that’s when I realized there was something was a little sinister,” Josh said. “I’ll never be able to prove if Costa Mesa withheld [Goldstein’s gunshot residue report] or if the DA’s office suppressed it and didn’t turn it over,” he said. “But that in itself raises a lot of questions. Why wouldn’t you test him? We do know he’s been an informant since at least 2004.”

‘I’m trying for the life of me [to understand]. Is it because of the show?’ - Lauri Peterson

Josh told us he has spoken to Goldstein since the shooting and Goldstein confirmed that investigators performed a gunshot residue report.

After his first trial was ruled a mistrial because his right to a speedy trial (a clause of the Sixth Amendment) was violated, Josh is due in court again on April 18 and will be represented by Joel Garson.

Garson told us that Goldstein “has taken the Fifth on [Josh]’s trial” and is also “getting ready to testify” in the other murder case.

He also explained that Josh is still on the hook for the crime because “two other witnesses said it was Josh” even though “the guy that was actually struck by the bullet said it was Goldstein’s car that he was struck from.”

Josh and Lauri estimate that there have been between 30 and 40 hearings so far for his second trial, as Josh now claims his privileged phone calls were monitored without his consent for the past year and a half, which would be another violation of his constitutional rights.

Lauri told us that the district attorney’s office is in the midst of transcribing these phone calls for the new district attorney on his case, as the previous lawyer retired.

“Now the judge is trying to decide if this was outrageous government conduct and if so, can there be a remedy for it?” Lauri said. “Well no, there can’t be a remedy. It would be like playing in the Super Bowl and one of the teams has the other team’s playbook for a year and a half before the Super Bowl! You can’t do that.”

“[The judge and district attorney] received 44 transcripts on Friday,” Garson later added. “We’re going through those. Some are hours long.”

Josh is also being sued by Lopez, 38, for damages sustained in the shooting. The case was filed in 2016 and is still ongoing, as is his divorce from Hannah, 25. She filed papers in September.

In January of this year, his pretrial hearing for being under the influence and possessing a controlled substance while in jail was canceled. Law enforcement told TMZ when he was first charged that he was caught with “pruno,” an alcoholic drink made of fruit, ketchup, sugar, milk and bread.

On top of that, Josh claims that he has been profoundly mistreated behind bars.

Lauri told us that Garson has requested surveillance video from the jail after a string of incidents that allegedly violated Josh’s rights. She said that Crime Watch was denied access to the jail to perform a lie detector test on Josh to help clear his name. Then the Innocence Project, a nonprofit legal organization that works to exonerate the wrongly convicted through DNA testing, wanted to send a bondsman to talk to Josh about potentially posting his $1 million bail (which Lauri won’t pay) and the police cruelly put him in a visiting booth with a metal stool for hours on end.

“Josh was in handcuffs,” Lauri told us, although she was not present. “He was in shackles and he was in ankle shackles and he was shackled to this metal stool. And so when the Innocence Project sent the bail bondsman, he waited for the bail bondsman even though the bail bondsman was waiting for Josh. They put Josh in a cell for two to three hours before they even let the bail bondsman come in.

“So the bail bondsman stayed with Josh for a few hours,” she said. “[The corrections officers] left Josh shackled to that stool for six hours after the bail bondsman left. They brought him back to his cell after midnight. He had no restroom breaks in over eight hours. He had no food and he had not been given his medication. They do that to him all the time because they can.”

The facility could not comment on his claims.

“We cannot speak directly to the allegations made by Mr. Waring, nor can we comment on Mr. Waring’s conduct inside of the jail. We have not been served with any litigation related to Mr. Waring to date. The Orange County Sheriff’s Department’s Custody Command is dedicated to providing safe and secure facilities for those entrusted to our care,” a public information officer for the Orange County Sheriff’s Department told us in a statement.

Josh told us he’s “hanging in there” for now, but Lauri is still trying to figure out how her son’s life led to this.

“I’m trying for the life of me [to understand],” she said. “Is it because of the show? Is it because of the notoriety he has? His lifestyle and the fact that he has been in and out of jail and [police] just frustrated by seeing him again? I don’t know.

“The silver lining to this for me is that my son is clean. I hate the fact of the way it was forced on him. I mean, I wish it would have been his choice to become clean. But regardless, I’m thankful for that and he is alive … for me, I really enjoy having my son back. The son that I knew before drugs got him. Once he hits the streets again, I don’t know what would happen, but I do feel Josh will get out. There’s no way someone can go sentenced life in prison for something like this. My brain can’t grasp that with no evidence.”