I've just updated pgAdmin to version 4.23 and PostgreSQL to version 12. I've also deleted all previous databases and pgAdmin installations. So it should have been a clean install (I've also cleaned up all the remains of previous versions).
Now when I'm attempting to connect to the local database server I get this before I can even type my password:
could not connect to server: Connection refused (0x0000274D/10061)Is the server running on host "localhost" (::1) and accepting TCP/IP connections on port 5433? 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 5433?
The service is running, I can use command line tool and it responds correctly but I can't use pgAdmin for some reason.
>psql -V
psql (PostgreSQL) 12.3
A duplicate of your question
PostgreSQL database service
Look through this thread as it states multiple solutions
https://stackoverflow.com/questions/24917832/how-connect-postgres-to-localhost-server-using-pgadmin-on-ubuntu
To access PostgreSQL over the network
Change listen_address localhost to * in file /etc/postgresql/{version_number}/main/postgresql.conf
# - Connection Settings -
listen_addresses = '*' # what IP address(es) to listen on;
Changes in pg_hba.conf
Add the following line in # IPv4 local connections:
host all all 0.0.0.0/0 md5
and comment
#host all all 127.0.0.1/32 md5
Related
I am on Windows 10 using WAMP, I added PostgreSQL and PhpPgAdmin, everything was working fine. Today I can not log in to PostgreSQL through PhpPgAdmin or a php_pdo web app.
I tried editing pg_hba.conf in 2 locations c:\PostgreSQL\pg96\init\ and c:\PostgreSQL\data\pg96\ and changed the 'method' to trust as per many answers here, none of the CLI answers worked either.
I also restarted "WAMP" and even the whole computer, but no luck.
The default password worked before postgres and root but not now.
How do I reset the postgre password?
UPDATE
runing psql -U postgres returns;
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?
contents of pg_hba.conf
# TYPE DATABASE USER CIDR-ADDRESS METHOD
# IPv4 local & remote connections:
host all all 127.0.0.1/32 trust
host all all 0.0.0.0/0 trust
# IPv6 local connections:
host all all ::1/128 trust
so after a lot more diging, it was not that the password was wrong, but for whatever reason PostgreSQL was not even running. Windows is such a PITA!
in the end, running pg_ctl -D "C:\PostgreSQL\data\pg96" start from CMD got it going. Now we will see if it starts tomorrow.... I miss my Unix Environment.
----- UPDATE -----
While the above code works, it is moving in the wrong direction.
goto Control Panel->Administrative Tools->Services and find 'PostgreSQL ...' in the list. Right click and open Properties.
My Startup type: was set to 'Automatic' but it was not starting, I set it to 'Automatic (Delayed Start)' and now it is working, automagically!
I'm trying to connect to a local instance of Postgresql using 127.0.0.1 as IP address but the connection is always denied:
⟩ psql -h 127.0.0.1 -U postgres -p 5432
psql: could not connect to server: Connection refused
Is the server running on host "127.0.0.1" and accepting
TCP/IP connections on port 5432?
My pg_hba.conf looks like this:
# TYPE DATABASE USER ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all password
# IPv4 local connections:
host all all 127.0.0.1/32 md5
# IPv6 local connections:
host all all ::1/128 trust
My postgresql.conf has the following entries:
listen_addresses = 'localhost, 127.0.0.1'
port=5432
unix_socket_directories = '/private/tmp'
I can however connect via the unix socket. What else could be blocking the connection?
Not sure what happened but a hard reboot of my laptop fixed the issue.
I'm trying to set up PostgreSQL remote connection on Ubuntu server.
I changed listen_addresses = 'localhost' to listen_addresses = '*' in /etc/postgresql/9.3/main/postgresql.conf
Then I added to postgre config file /etc/postgresql/9.3/main/pg_hba.conf lines
host all all 0.0.0.0/0 md5
host all all ::0/0 md5
host all all all md5
But when I'm trying to connect remote DB by psql -U db_user -h host -d db_name it hangs and show message
psql: could not connect to server: Connection timed out
Is the server running on host "host_address" and accepting
TCP/IP connections on port 5432?
PgAdmin connection hangs as well
Had the same issue using amazon EC2 service
Solution:
1) Go to security group for your server instance
2) Edit inbound rules
3) Allow all traffic for your IP
I'm having issues connecting to my PostgreSQL database from an online source.
PostgreSQL seems to be setup up fine it is running on it's default port 5432 and the postgresql.conf has the following line
listen_addresses = '*'
And the pg_hba.conf has the following
host dbname usname all md5
I can connect to the PostgreSQL database from a different machine using the following credentials in pgadmin
Name local
Host 192.xx.xx.xx
Port 5432
Maintenance DB dbname
Username usname
Password psword
Using these I can connect perfectly it seems to work fine.
Then I forwarded the port 192.xx.xx.xx:5432 on the ADSL router and checked it using the public IP address 197.xx.xx.xx (visible to the internet IP)
http://www.canyouseeme.org/
Where I can see the port was forwarded ok.
However when I try to connect using
Name online
Host 197.xx.xx.xx
Port 5432
Maintenance DB dbname
Username usname
Password psword
I get the server doesn't listen error message
could not connect to server: Connection refused (0x0000274D/10061) Is the server running on host "197.xx.xx.xx" and accepting TCP/IP connections on port 5432?
Why is this? Do I need to add an extra step to making it accept connections through port forwarding?
This question already has answers here:
Connection refused (PGError) (postgresql and rails)
(6 answers)
Closed 9 years ago.
I am trying to connect postgresql but I am getting this error.
org.postgresql.util.PSQLException: Connection refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.
My pg_hba.conf file is like this.
TYPE DATABASE USER CIDR-ADDRESS METHOD
# IPv4 local connections:
host all all 127.0.0.1/32 md5
# IPv6 local connections:
host all all ::1/128 md5
I would be much obliged if anyone please be so kind enough to explain whats hoing on here and how should I correct it.
The error you quote has nothing to do with pg_hba.conf; it's failing to connect, not failing to authorize the connection.
Do what the error message says:
Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections
You haven't shown the command that produces the error. Assuming you're connecting on localhost port 5432 (the defaults for a standard PostgreSQL install), then either:
PostgreSQL isn't running
PostgreSQL isn't listening for TCP/IP connections (listen_addresses in postgresql.conf)
PostgreSQL is only listening on IPv4 (0.0.0.0 or 127.0.0.1) and you're connecting on IPv6 (::1) or vice versa. This seems to be an issue on some older Mac OS X versions that have weird IPv6 socket behaviour, and on some older Windows versions.
PostgreSQL is listening on a different port to the one you're connecting on
(unlikely) there's an iptables rule blocking loopback connections
(If you are not connecting on localhost, it may also be a network firewall that's blocking TCP/IP connections, but I'm guessing you're using the defaults since you didn't say).
So ... check those:
ps -f -u postgres should list postgres processes
sudo lsof -n -u postgres |grep LISTEN or sudo netstat -ltnp | grep postgres should show the TCP/IP addresses and ports PostgreSQL is listening on
BTW, I think you must be on an old version. On my 9.3 install, the error is rather more detailed:
$ psql -h localhost -p 12345
psql: could not connect to server: Connection refused
Is the server running on host "localhost" (::1) and accepting
TCP/IP connections on port 12345?