They needed a Jason Tovey penalty in the 62nd minute to secure what was their fifth Magners League win of the season.
For Connacht it was yet another narrow defeat. Their sixth losing bonus point was well deserved but it will feel like little consolation as they had a shot at victory.
Miah Nikora aimed a drop goal at the posts with just over five minutes remaining, however his kick was blocked down by a determined home defence.
The first half provided most of the fireworks. Connacht started with purpose but it was the home side who scored first after just three minutes thanks to a counter attack sparked initially by full back Will Harries.
The ball was spread wide to winger Brew, who linked brilliantly with Riley, taking a return pass and sprinting home.
Tovey's successful conversion stretched the lead to 7-0 and his side took heart from that start, controlling much of the first quarter.
Although, the Dragons' young out-half was wayward with two penalty kicks in the opening quarter, including one from straight in front of the posts.
Connacht were sparked into action after that miss with Ian Keatley kicking a penalty, after the Connacht maul was pulled down, to get the westerners on the scoreboard.
Then came their try, a brilliant attacking move set up by young centre Eoin Griffin who came on to a Nikora pass at full speed, jinked left and then right to draw the cover before releasing Troy Nathan out wide for an easy score in the corner.
Keatley converted to give Connacht a 10-7 lead coming up to the half hour mark in what was a remarkable turnaround.
Then, for the second time in the game, a counter attack provided the Dragons a platform for a score.
Harries was instrumental again with a pinpoint pass for Brew on halfway, the winger burst clear down the line before passing back inside to Riley for a brilliantly taken second try which Tovey converted to give the home side a 14-10 advantage.
However, Connacht just would not lie down in this contest and right on the stroke of half-time, Keatley was presented with a third look at the posts and he did not disappoint, converting the three point to make it 14-13 at the break.
The second half was far more physical and Connacht seemed to edge that battle in the third quarter.
The Dragons had dominated possession and territory but had little to show for it and when Keatley pushed the visitors into a two-point lead after 51 minutes with a long range penalty, the momentum was with the Irish side.
However, a key turning point came when Sean Cronin was penalised for not rolling away and Tovey took advantage for the home side with a crucial penalty to edge the Dragons into a 17-16 lead which they would not relinquish.
|Newport Gwent Dragons Score Card|
|Connacht Rugby Score Card|