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
Related
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
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 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?
I'm trying to set up a JDBC connection to postgres from another program.
When I run the program, I get the following error:
[2013-03-24 03:14:10,542][ERROR][org.elasticsearch.river.jdbc.strategy.simple.SimpleRiverSource] while opening read connection: jdbc:postgresql://[my postgres server's ip address]:5432/[my database name] FATAL: no pg_hba.conf entry for host "[my client ip address]", user "postgres", database "[my database name]", SSL off
I can connect to the server successfully with a command line client by running:
psql -d [my database name] -U postgres -p 5432 -h [my postgres server ip address]
I think then that I have a unix socket connection that works but need to enable tcp connection in the pg_hba.conf, but it looks like I already have several tcp connections allowed in the pg_hba.conf file below... can anyone advise what I may be doing wrong?
My pg_hba.conf contains the following uncommented lines:
hostssl all all 0.0.0.0/0 md5
host all all 10.0.0.0/8 md5
local all postgres peer
local all all peer
# IPv4 local connections:
host all all 127.0.0.1/32 md5
# IPv6 local connections:
host all all ::1/128 md5
If doing devel on local computer and booth program and DB run on the same machine go with:
# IPv4 local connections:
host all all 127.0.0.1/32 trust
I have a VM set up with Vagrant that has Postgres running on it (on port 5432), forwarded to port 8280 on the host machine.
I have set the password for the default user and I can connect locally just fine.
I have been trying to set up access from the host machine over port 8280, and I have been unable to get it working with 'MD5' as the trust method.
I have set up postgresql.conf to listen on all addresses:
# postgresql.conf
listen_addresses = '*'
and I have configured pg_hab.conf as follows:
# pg_hab.conf
#TYPE DATABASE USER CIDR-ADDRESS METHOD
host all all 0.0.0.0/0 md5
With all of these settings, if I run the following command from my host machine:
psql --host=127.0.0.1 --port=8280 --username=postgres -d mydb -c '\l'
I am prompted for the password, and then I get:
psql: FATAL: password authentication failed for user "postgres"
If I then change the METHOD from 'md5' to 'trust' I'm not asked for a password and I can connect as expected. My question is - why can't I connect using 'md5', which is what I want to be able to do? I know that the password I am entering is correct (I have changed it), but for some reason it isn't working.
I had the same exact problem. The issue was on the host side, basically the firewall was blocking the port I was using. So this is what I did (I am using OSX Mavericks)
Open the port (Host)
sudo ipfw add 7000 allow tcp from any to any dst-port 7001
Modify Vagrantfile in order to allow portforwarding
config.vm.network "forwarded_port", guest: 5432, host: 7001
Edit postgresql.conf (Guest)
listen_addresses = '*'
Edit pg_hba.conf (you might want to tune this better)
host all all 0.0.0.0/0 md5
Now, from the host connect normally using the port (in my case 7001) and 'localhost' as host address
You need to set a password for the postgres user. It does not have one by default, so you cannot connect.
ALTER USER postgres PASSWORD 'somepassword';
Your local connections probably work because they're using unix sockets with peer authentication, not TCP/IP. If you use:
psql -h 127.0.0.1 -U postgres postgres
on the VM, you'll probably find that that fails too, because you're actually testing TCP/IP based connections now.