Is there a way to connect to postgres when have error "sorry, too many clients already "?
Slots reserved for postgres superuser
PostgreSQL reserves a few connections for superusers. If your application is not using superuser connections you can connect as a superuser (eg postgres). Then run diagnostic queries like:
select * from pg_stat_activity;

superuser_reserved_connections setting
See the superuser_reserved_connections setting in the Postgres configuration. Defaults to 3 reserved slots.
To quote the version 11 documentation:

Determines the number of connection “slots” that are reserved for connections by PostgreSQL superusers. At most max_connections connections can ever be active simultaneously. Whenever the number of active concurrent connections is at least max_connections minus superuser_reserved_connections, new connections will be accepted only for superusers, and no new replication connections will be accepted.
The default value is three connections. The value must be less than max_connections minus max_wal_senders. This parameter can only be set at server start.