Sean McConville hit the crossbar with Stanley's first chance, but the Cobblers responded with striker Marc Richards volleying wide.
Accrington's Josh Windass fired off target and had a close-range effort saved before Richards headed in Ricky Holmes' cross to put Northampton ahead.
Matt Crooks had a late chance for Stanley, but the home side held on.
Northampton Town ended Accrington Stanley's seven-game unbeaten run in League Two with a narrow victory.