Gorham’s Dan Foley proved on Wednesday night’s episode of “Survivor” that he’s a pretty good judge of his biggest weakness – his mouth.

And he kept it shut long enough to survive the third episode of the season. Now, the 48-year-old postal worker is one of 15 people still in the running for the CBS show’s $1 million prize.

But as in all three episodes he’s been on, there was a moment Wednesday night when Foley drew the ire of his competitors because of something he said. Just a few minutes into the episode, Foley was seen lounging around his primitive campsite with the other members of his tribe. They were talking about how they weren’t getting much sleep on their bamboo beds.

They seemed to be kidding and joking with each other when Rodney Lavoie, a 24-year-old contractor from Boston, said to Foley “Go back to sleep, Dan.” To which Foley responded “Your mother’s an (expletive).”

Lavoie got angry. “Don’t disrespect my mother. Watch your mouth.” Lavoie said that Foley had “crossed a line” with him.

“I think my best characteristic is also my worst characteristic, my mouth,” Foley said, while alone and talking to the camera. “Sometimes it takes an anvil dropped on my head for me to realize it.”

Maybe Lavoie’s anger was the anvil that Foley needed. For the rest of the episode, he was seen getting along with his tribe mates, even lending a compassionate ear to Lavoie when he got frustrated with another teammate.

On the episode’s immunity challenge, Foley helped his team win for the second week in a row. The challenge involved five tribe members carrying a water bucket riddled with holes over an obstacle course, with the goal of keeping enough water in the bucket to fill a larger bucket before the two other teams could.

Foley was seen being one of the key people in the challenge, running and helping to lift the bucket over obstacles. Because his tribe won immunity, someone from another tribe was voted off, and Foley will be on at least one more episode.

This season of “Survivor” was filmed in Nicaragua over 39 days last August and September, and began airing Feb. 25 with 18 participants. Foley has some idea of how far he progressed, though he’s contractually required not to say.

But he has been sharing his “Survivor” experience with fellow Mainers. He’s been hosting viewing parties at local restaurants, so friends and fans can join him in watching the episodes. He’s planning to watch next week’s episode at Thatcher’s Restaurant & Sports Pub in South Portland.

Foley’s devotion to “Survivor” is fanatical. He had been trying to get on the show since its first season, in 2000, and had applied more than 100 times.

The next episode of “Survivor” will air March 18 at 8 p.m. The finale will be sometime in May.