PG defaults to a limit of 32 connections. This can be overridden by starting the postmaster with a higher value - I use 100 on my personal server. "postmaster -N 100 ..."
You should match the PG number of backends to the number of connections you let OpenNSD make (perhaps planning for at least one more PG backend so you can be assured of having one available to use with PSQL in a pinch). Doing so will cause OpenNSD to make the thread wait or give a reasonable error rather than crashing your script.