Derby, fourth in League One, went into the match on the back of 14 matches unbeaten in all competitions but were quickly overrun by the Premier League side, who took the lead in the 10th minute with a close-range volley from Jarrod Bowen.
Bowen went 12 matches without a goal before netting twice against Everton last week and now has three in his last two games.
The forward then crossed for striker Michail Antonio to head in a second goal five minutes after the interval to break his own goal drought stretching back to November.
David Moyes' side saw out the victory without conceding many chances, recording back-to-back wins for the first time since October, and Bowen said he hoped the win would boost his side, who are 16th in the table, one point above the relegation zone.
Bowen and Antonio send us through ⚒️#DERWHU pic.twitter.com/7HUriMaLKo
— West Ham United (@WestHam) January 30, 2023
"Two wins on the bounce is good for us. It's all about results and momentum and we can use this as a real springboard," Bowen said.
Midfielder Pablo Fornals added: "Everyone knows it hasn't been an easy season so every game we can win gives us massive confidence.
"We work hard every day in training to get a chance and then you have to take it. That's what the players tried to do tonight."
West Ham get United in fifth round
For the fifth time in seven seasons, West Ham will travel to face Manchester United in a domestic cup.
With Premier League fixtures against Newcastle, Chelsea, and Tottenham also on the horizon, at least Moyes has managed to get a tune from his players to restore confidence levels.