ST. LOUIS – Nobody’s better than the St. Louis Cardinals when they can’t afford to lose.

Adam Wainwright went all the way on the mound, and St. Louis got two-run homers from David Freese and Matt Adams to beat the Pittsburgh Pirates 6-1 on Wednesday night, advancing to the NL Championship Series for the third straight season.

Wainwright scattered eight hits in his second dominant win of the division series, coming through for the Cardinals in a winner-take-all Game 5. St. Louis gets to stay home to open the NLCS against the well-rested Los Angeles Dodgers on Friday night.

“I wanted it bad. It’s probably the most nervous I’ve ever been,” Wainwright said. “I don’t get a whole lot of nerves when I pitch. Before I pitched today, I was pretty nervous.”

By ending Pittsburgh’s storybook season, the Cardinals improved to 8-1 when facing postseason elimination the past three years. They also won Game 5 of the NL division series in Washington last year, even though Wainwright got rocked, and at Philadelphia in 2011.

Freese homered in the second inning off rookie Gerrit Cole and Adams connected in the eighth against reliever Mark Melancon to make it 5-1. Pete Kozma added an RBI infield single, and Wainwright finished it by striking out Pedro Alvarez with two on.

“I’m just so fired up for this team and this city right now,” Wainwright said. “Cardinal fans were rockin’ today and I’m just fired up to be here.”

Alvarez became the first player with an RBI in his first six postseason games on a fluke hit that caromed off first base in the seventh. But the Pirates, who ended a record streak of 20 straight losing seasons this year, were held to one run in each of the final two games of their first playoff appearance since 1992.

Despite their turnaround and win over Cincinnati in the NL wild-card game, the Pirates haven’t won a postseason series since the 1979 World Series.

Cole beat the Cardinals with an impressive effort in Game 2. They got to him early this time even though his fastball hit 100 mph in the first inning against Matt Holliday.

Freese made the kid pay for a full-count walk to Jon Jay with two outs in the second, lining a 1-2 pitch into the visitors’ bullpen in left.

The Pirates had the bullpen up in the fourth after Yadier Molina’s infield hit and a throwing error put runners on second and third. Cole gave up just three hits over five innings but was lifted for a pinch hitter in the sixth.

“He’s a stud. He’s a big-time player at big-time moments,” Wainwright said. “And that’s what we expect of him and that’s what he continues to deliver.”

The Pirates scratched out their lone run on two infield hits and the single by Alvarez that looked to be a harmless inning-ending groundout before it hit the bag.