WebFaction
Community site: login faq

psql: could not connect to server: Connection refused Is the server running on host "local host" and accepting TCP/IP connections on port 5432?

I am Trying to access the application after some time when application is running then automatically service of postgresql database is stop.it happens when i am trying it on live server

Thanks in Advanced Regards, Gautam V Panpatil

asked 23 Sep '13, 01:03

Gautam Panpatil
114
accept rate: 0%

Are you actually using "local host", or "localhost"?

(23 Sep '13, 01:13) ryans ♦♦

Shared PostgreSQL instances will be restarted once in a while for various reasons for which you have little control on.

If you are reusing the same connection or if you are using a connection pool, you will need some way to detect the disconnected state of the database and invalidate the connection or the pool. I'm personally using Python and SQLAlchemy to handle PostgreSQL connections. They have an interesting feature for handling database disconnections in a pessimistic way (see http://docs.sqlalchemy.org/en/latest/core/pooling.html#disconnect-handling-pessimistic ). Before reusing a connection from the pool, it simply does a 'SELECT 1' query. It that query fails, the pool is recycled and new connections are created. This feature should be available with any language or tool you are using for your application. If it is not available, you can easily implement it yourself.

An alternative is to setup a private PostgreSQL instance and manage it yourself but that will consume a share of your total available memory. See http://docs.webfaction.com/software/private-databases.html .

permanent link

answered 16 Jun '14, 14:14

delizseemack
12
accept rate: 0%

edited 16 Jun '14, 14:14

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×109
×1

question asked: 23 Sep '13, 01:03

question was seen: 2,177 times

last updated: 16 Jun '14, 14:14

                              
WEBFACTION
REACH US
SUPPORT
LEGAL
© COPYRIGHT 2003-2021 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM