I cannot connect to PostgreSQL server from PgAdmin III , so I get this error:

Error connecting to the server: server closed the connection unexpectedly

This probably means the server terminated abnormally before or while processing the request.

I get the same error when I try connecting from psql.

I have got this error 2 days ago but after restarting the computer the problem disappears , but this time I have restarted it too many times vainly.

I'm using PostgreSQL 9.0.5 on windows 7 with ArcSDE 10.1 (Arcgis Spatial Database add-on), I have deactivated the antivirus and firewall.

I have tried to reinstall PgSQL but the problem persists.

How I can connect to my Pgsql service and get rid of this error?

  • Please put the information in the comment into the question! Also, are you running Linux or Windows (or other)? What does ps -ef | grep post show (or Windows equivalent) show?
    – Vérace
    Oct 14, 2020 at 11:03

2 Answers 2


It looks like broken data file or broken indexes. If this problem grows, then it can shows some deep system problems - problems with hw (memory, CPU), os (antivirus)... Try to use a commands executed from command prompt for database access repairing a) reindexdb - refresh all indexes, b) pg_dump - recheck a readability of data files.

  • Could you be more specific about how to do a) and b)? Mar 26, 2022 at 6:24
  • @smwikipedia - look on SQL command REINDEX and shell command pg_dump or pg_dumpall Mar 26, 2022 at 6:43

This error can also occur when the postgres service is not configured to listen on the address from which you are attempting your client connection. This may be the case if you can connect to the service from some hosts, but receive this error message from others.

If you are able to connect to the service from another host, inspect the running configuration value of listen_addresses.

show listen_addresses;

select * 
from pg_settings
where name = 'listen_addresses';

In short: a configuration value of * will allow the service to listen on all addresses. If you see another value (such as localhost, a hostname, or an IP address), then you may wish to add a record. You can do so by adding a comma and then your addresses to the listen_addresses line of postgresql.conf and restarting the service. Note that if you add an IP address it cannot be a CIDR range

See also: posts on StackOverflow, ServerFault

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.