How to connect pgadmin 4 to an external server? - postgresql

I just created a server (droplets) in digital ocean, install postgresql, up there well, it works on the console. My problem is when I try to connect through pgadmin.
could not connect to server: Connection refused (0x0000274D/10061)
Is the server running on host "165.22.184.123" and accepting
TCP/IP connections on port 5432?
Look for information and modify the file
/etc/postgresql/10/main/postgresql.conf
where says listen_addresses='localhost' by listen_addresses='*'.
Also add a line to host all all 0.0.0.0/0 md5 to the file /etc/postgresql/10/main/pg_hba.conf and I still have the same problem. Do I have to do some additional configuration?

Related

psql: error: connection to server at "localhost"

Let me first mention I don't have admin privilege on my PC, So I could not install PostgreSQL with the normal process. I just download the binary files from here enterprisedb.com/download-postgresql-binaries,
and added it to environment variable paths.
My problem when I try to start a new server from pgAdmin it gives me the below error.
connection to server at "localhost" (::1), port 5432 failed: Connection refused
(0x0000274D/10061) Is the server running on that host and accepting TCP/IP connections?
connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused
(0x0000274D/10061) Is the server running on that host and accepting TCP/IP connections?
I searched a lot for a solution
The first recommendation I got is to restart postgress from windows services but I couldn't find it.
Second recommendation was to edit the psogress config file but also I can't find it at all they say that I can find it in the main directory of postgress.

Cannot connect postgreSQL server to pgAdmin 4

I know there are a lot of similar questions on this site, but so far I've been unable to find any answers. I have a postgres 13 server running on a WSL distro, ubuntu 20.04. I am trying to connect a gui to the server. I've tried Postbird and pgAdmin 4, both give me a similar error:
'Unable to connect to server:
could not connect to server: Connection refused (0x0000274D/10061)
Is the server running on host "localhost" (::1) and accepting
TCP/IP connections on port 5432?
could not connect to server: Connection refused (0x0000274D/10061)
Is the server running on host "localhost" (127.0.0.1) and accepting
TCP/IP connections on port 5432?'
Steps I have tried:
I can connect to the server inside of ubuntu by running psql.
I have changed the postgresql.conf file to include listen_addresses = '*'
I have modified the pg_hba.conf file to look like:
pg_hba.conf
I have confirmed that the server is indeed running on port 5432.
Thanks for reading. Any advice would be greatly appreciated.
Ok! So my issue was indeed the pg_hba.conf file. I had to add a line at the bottom
host all all 0.0.0.0/0 trust
Once I did that, I restarted my server and was able to connect.

PostgreSQL server Connection error: could not connect to server

I am using pgAdmin4 and developing a node.js app.I had an abrupt shutdown of the computer and I can no longer connect to the postgresql server.
The error I get when trying to connect is :
psql: could not connect to server: Connection refused (0x0000274D/10061)
Is the server running on host "localhost" (::1) and
accepting TCP/IP connections on port 5432?
could not connect to server: Connection refused (0x0000274D/10061)
Is the server running on host "localhost" (127.0.0.1) and
accepting TCP/IP connections on port 5432?
I tried to run postgres -D /usr/local/var/postgres/ as suggested in this SO answer. However it gave me the following error :
postgres: could not access directory "usr/loval/var/postgres": No such file or directory
Run initdb or pg_basebackup to initialize a PostgreSQL data directory.
So I just manually deleted the postmaster.pid file inside the PostgreSQL/.../data folder. But I still cannot connect to the database server.
I have checked the postgresql.conf file, and
the listen addresses is already set as listen_addresses = '*', and the port is set to 5432.
I also tried deleting the pgAdmin file in the AppData/Roaming folder.But it gave me an error:
The application server could not be contacted
and then afterwards the same problem of not being able to connect to the server happens.
Funny enough, it was a matter of just deleting the pdAdmin file in AppData/Roaming folder, and then restarting the computer and restarting the pgAdmin4. That solved it for me.
Meet the same challenge while settings up PostgreSQL to work with a Python/Django project.And i resolved the issue here, after reading the official PostgreSQL-9.6.16 documentation.

Postgres PgAdmin 3: Server doesn't listen - Tried everything

I tried opening ports in IPTables,
Set Listen address to *
Added
host all all 23.81.27.0/24 trust
and even
host all all 0.0.0.0/0 trust
YouGetSignal shows the port is closed, and i can't connect to my DB via PgAdmin.
I get
could not connect to server: Connection timed out (0x0000274C/10060)
Is the server running on host "23.81.27.206" and accepting TCP/IP
connections on port 5432?
Any ideas?
I already tried to reboot Postgresql, IPtables, and the server.
With this error
could not connect to server: Connection timed out (0x0000274C/10060)
Is the server running on host "23.81.27.206" and accepting TCP/IP
connections on port 5432?
no need to modify hba_file. Either listen_address in postgres.conf not set to listen on external iface, or firewall blocks it/ not translating/ othernetwork issues. First case often people modify listen_address in wrong postgres.conf or do not restart server. To make sure it did not happen to you, ssh to server, psql to it and check
show config_file;
show listen_addresses;
If those ok, then still on remotes shell :
psql -h 23.81.27.206
If you get connected, stop looking into postgres config - check network (firewall, PAT,NAT,routes, your client connection ((maybe you not connected to the Internet?..)))
Turns out it was IPTables after all. I did "Service iptables stop" And i can connect. I can't manage to allow my ip/open that port. But i guess this is how i have to do it. i just enable it whenever im done.

Can't connect to the default server of pgAdmin 4

I have just installed the pgAdmin-4, and trying to connect to the default server installed with it (PostgreSQL 9.5). It asks for the password (Which I assume by default it's "postgres"), however, I keep receiving the following message:
could not connect to server: Connection refused (0x0000274D/10061) Is the server running on host "localhost" (::1) and accepting TCP/IP connections on port 5432? could not connect to server: Connection refused (0x0000274D/10061) Is the server running on host "localhost" (127.0.0.1) and accepting TCP/IP connections on port 5432?
I am working on Windows 7.
Any ideas on how to fix this problem?
The first thing is to remove pgadmin from the problem. Try to connect with the command line using psql - if you get the same message you know that the problem is not with pgadmin. If the problem continues with psql then probably your configuration of postgresql is not complete. The issue might be in the file pg_hba.conf - this file controls who is allowed to connect to the backend. You might also check that the server application is running, using an appropriate Windows utility.