Check number of postgresql connections

psql template1;

SELECT COUNT(*) FROM pg_stat_activity;

You can see max allowed connections with SHOW max_connections; - but this is just as easily read from the postgresql.conf in /etc/postgresql/(version).. etc