This problem arises when your server by overloaded from requests. This problem we can solve whit two different ways. First is add the interval between requests second is adding connection slots which by default is 100. We will suggest you add connection slots because increasing requests interval can affect on the quality of your code. But if you want increase interval between requests you can see this.
To adding connects we need:
To log into PostgreSQL server.
There we will increase the value of “superuser_reserved_connections”. We need to open the file “postgresql.conf” which is located in “/var/lib/pgsql/9.x/data/postgresql.conf”. Then increase the value of “max-connections” from default 100 to e.g. 200 or how much you need.
Note: “9.x” is the version of PostgreSQL. That can be different and you need to know which one do you use: to know this check here.
And finally restart the PostgreSQL services. To do this use the following commands:
For Debian system
$ sudo systemctl restart postgresql
For Red Hat system
# systemctl restart postgresql-9.x.service