unable to connect to server for Postgres

前端 未结 7 1748
刺人心
刺人心 2021-02-02 09:48

I have a problem to connect server for Postgres after I updated my windows.Before I update there is no problem to open the database. My database in Postgres also gone. When I wa

相关标签:
7条回答
  • 2021-02-02 09:55

    I think the problem is with your server listening to default public IP address. For example in the PostgreSQL package, your sever is set to listen to localhost as default public address which when you launch/ run database, the address might be something like '127.0.0.1'

    To fix you can try change localhost to '' as in "listen_addresses = ''".

    As seen as "listen_addresses = 'localhost'" under "Connection Settings" in the postgresql.conf file.

    Also to access your postgresql.conf file, go to:

    On Windows, the file is in /Program Files/PostgreSQL//share/. On Ubuntu, these files are in /etc/postgresql//main/.

    P.S: Changing the defaults 'localhost'; to '*' will let your server listen to any public database address either "localhost, 127.0.0.1 etc.

    I know you might have fix this, just for others that might run into the same issue in the future. Hope it was helpful

    0 讨论(0)
  • 2021-02-02 09:57

    I got this error message when I moved my database to another computer.

    I also got some error messages when starting the server first with

    pg_ctl -D /wherever/your/database/is start

    which were

    pg_ctl: another server might be running; trying to start server anyway server starting

    DETAIL: File "/wherever/your/database/is/PG_VERSION" does not contain valid data.

    HINT: You might need to initdb.

    In my case rather than running initdb this command actually fixed the issue

    pg_ctl -D /wherever/your/database/is restart
    
    0 讨论(0)
  • 2021-02-02 10:08

    On windows, Just go to the 'Services'. Start/Restart the postgresql-X64 service. It worked for me as my service was in stopped state somehow.

    worked for me

    0 讨论(0)
  • 2021-02-02 10:10

    On windows, Just go to the 'Services'. Start/Restart the postgresql-X64 service. It worked for me as my service was in stopped state somehow.

    0 讨论(0)
  • 2021-02-02 10:10

    There are two items to configure if your server isn't on localhost:

    • find your postgresql.conf and add your server's public IP address to the end of the setting listen_addresses (separate multiple entries by commas); uncomment the line if it is commented out (e.g. with '#')
    • add a line to pg_hba.conf containing your client's IP address - you may copy the line containing 127.0.0.1 and change only the IP address

    On Ubuntu, these files are in /etc/postgresql/<version>/main/.

    0 讨论(0)
  • 2021-02-02 10:11

    In my case I couldnt' open the pgAdmin4, for some reason. I use Postgresql 10 and pgAdmin4

    The port in the postgresql.conf was not the same as in the pgAdmin4 --> postgreSQL 10 --> properties --> Connection --> port.

    I fixed it and it worked. Check if those 2 are in line.

    0 讨论(0)
提交回复
热议问题