Allow port arbitrary port (such as 5432) open on El Capitan.
The ipfw firewall has been replaced by pf in Mac OS X Lion and later. Try looking at the man page for pfctl to start.

An old, but still good cheat sheet for pf

As for debugging network connections on the Mac, I would run netstat to see what ports had listeners. And possibly sudo lsof -i to see which process had which port open.