It turns out all the Red Bulls needed to break their malaise was a return to their old formation. And a little old-fashioned hate.

Mix that all in, and they had a 2-0 slump-busting shutout of archrival D.C. United in front of 20,104 fans Saturday night at Red Bull Arena.

“We know that, especially in these rivalry games, if we’re not up for the challenge, we can just get cleaned up on the field,’’ coach Jesse Marsch said.

“We knew it was going to be a battle,’’ Sacha Kljestan said, “and for the most part we got the better of them.”

The Red Bulls (3-3-1, 10 points) had lost back-to-back games, and were winless in four while being outscored 8-2. But after ditching the new 4-2-2-2 formation with which they had struggled this year and going back to the 4-2-3-1 with which they had excelled since Marsch’s arrival, the offense finally clicked.

It wasn’t a coincidence.

“It helps that we’ve gone back to our old formation, and guys just feel a little more comfortable,’’ Kljestan said. “You look at the pieces that a team like [RB] Leipzig does, they’ve got different types of guys. With the guys we have, the comfort level is just higher in the 4-2-3-1. It’s been over two years now that we’re playing in it and obviously I’ve been running in that central spot for some time now. So yeah, the comfort level is higher.”

Always dangerous on set pieces, the Red Bulls broke through right after halftime. Kljestan put in a 46th minute corner and Alex Muyl — who is starting to blossom into more than just a workrate grinder — beat United left back Taylor Kemp to the ball, heading it off keeper Bill Hamid’s hands for his first goal of the season.

“I had a chance in the first half and it slipped off my head. … I knew if it came again I had to make sure I get it on frame,’’ Muyl said. “We knew coming back home that this was going to be a big opportunity. … It’s not easy to win away games in this league, so we knew this was a must-win for us.”

In the 62nd minute, Bradley Wright-Phillips punished United’s sloppy defending. He split centerbacks Bobby Boswell and Steve Birnbaum, ran onto Felipe’s through ball and beat Hamid, putting a shot right through the wickets.

It was the first time the Red Bulls had scored twice in a game all season (one of their tallies in an opening 2-1 win was an own goal). Wright-Phillips and Daniel Royer had been the only Red Bulls to score, and they had just three goals.

“The front four had to look at ourselves. None of us were playing out if our skin. We had to look at ourselves … and say are we playing good enough, and we [weren’t],’’ said Wright-Phillips, who agreed facing their rival and reverting to the 4-2-3-1 both helped. “We’re obviously used to it. We’ve been playing it for two years.

Either way the performances before were down to just not working hard.”