I'm running an Oracle Linux 8 instance which I connect to via ssh public key authentication. There I've installed PostgreSQL but I can't seem to access it locally (from DBeaver for example).
I've made these following changes:
set listen_addreses to '*' at the postgresql.conf
added "host all postgres 0.0.0.0/0 md5" at the end of pg_hba.conf
I added postgresql to the firewall by running
sudo firewall-cmd --add-service=postgresql --permanent
sudo firewall-cmd --reload
I even tried disabling the firewall with
sudo systemctl stop firewalld
sudo systemctl disable firewalld
without any success.
And of course I restarted postgresql after the changes with
sudo systemctl restart postgresql.service
However nothing was successful. I've had success by making these changes on other servers previously, but not this time.
And yes postgresql is definitely running
Any help would be appreciated. Thank you.
EDIT:
Error message:
OperationalError: connection to server at "<ip address>", port 5432 failed: Connection timed out (0x0000274C/10060)
Is the server running on that host and accepting TCP/IP connections?
Connection details:
Related
I install pgadmin4 using the following command sudo install pgadmin4 and then I installed postgresql using sudo install postgresql . In my terminal I ran the command psql -U postgres -h localhost
It shows connection refuse
Then I go to pgadmin4 and created a server and I wanted to connect to the server it shows
pgadmin connection refuse
Then I wrote host all all all md5 in pg_hba.conf file and I wrote listen_addresses = '*' to postgresql.conf file. and I wrote the following command sudo service postgresql restart but again It shows connection refuse message.
I wrote psql and it shows connections on Unix domain socket
Can you please help me in this regard? What I have missed?
I installed Ubuntu 14.04 on Azure recently. Have been trying to connect to PostgreSQL but the server refuses the connection. I checked and confirmed that it was online. I also tried changing the settings to trust on pg_hba.conf and I also edited the Postgresql.conf file to listen to all addresses. Furthermore, I checked my firewall settings on Windows and allowed Pgadmin 4 to go through. Despite following all the instructions in this question (Unable to connect PostgreSQL to remote database using pgAdmin), I was unable to connect. What should I do?
I once had such issue with pgAdmin4 on win 10. Here is the step I took to connect to my remote server
first enable port 5432 to pass through firewall in ubuntu:
sudo ufw allow 5432/tcp
Then edit your postgresql.conf file and add
listen_addresses = "*"
file can be found at /etc/postgresql//main/postgresql.conf
Proceed to edit pg_hba.conf and add
host all all 0.0.0.0/0 md5
Now stop the server using/etc/init.d/postgresql stop and restart /etc/init.d/postgresql start
You should be able to connect now. However, you can allow pgAdmin4 to pass through the windows firewall
control panel > System and Security > Allow an app through windows firewall
You can also allow same app for any antivirus you've installed
Note:
If you still cannot connect, you can reset your postgres user's password NOT linux default user
sudo -u postgres psql postgres
# \password postgres
Enter new password
Then use this new password to connect your pgAdmin4 using
postgres as Maintenance database
postgres as username
then new password
Hopefully, you should be able to connect
Enable your postgresql server to start at boot
sudo systemctl enable postgresql
Start your postgresql server
sudo systemctl start postgresql
verify your postgresql server is running:
sudo systemctl status postgresql
When I'm trying to connect to Postgres on remote cloud . It is showing :
psql: server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
Local system -- Postgres 9.3 (windows)
Remote System is on Azure -- Postgres 9.2(centos)
Command I'm using: psql -h "abc.cloudapp.net" -p 5432
I've set the end-point as 5432 in azure
changed the postgresql.conf to "*" to allow connection
and changed the pg_hba to (host all all ip/24 md5)
Please help me out on this.
Endpoint is OK, and you need to set up the network security group as well.
Try to define not just 5432, but the range of ports (1024-65536 for example).
UPD: I was able to create the CentOs 7.0 + PostgreSQL and connected to that instance:
sudo yum install postgresql-server postgresql-contribs
sudo postgresql-setup initdb
sudo vi /var/lib/pgsql/data/pg_hba.conf
Edit 127.0.0.1/32 to 0.0.0.0/0
sudo systemctl start postgresql
sudo systemctl enable postgresql
sudo vim /var/lib/pgsql/data/postgresql.conf
sudo service postgresql restart
sudo service postgresql restart
sudo -u postgres createuser --superuser azureuser -P
Then i downloaded pgAdmin and connected to that. (see screenshot) (do not pay attention to the test1 database, just change it to postgres).
We have installed couchdb on Centos 7 and we are having issues connecting to it from the internal IP address or public IP address on an Amazon Centos Image. This message I am getting:
curl: (7) Failed connect to <public_ip>:5984; Connection refused
curl: (7) Failed connect to <internal_ip>:5984; Connection refused
But if I hit it locally it will work no problem:
curl 0.0.0.0:5984
Response: {"couchdb":"Welcome","uuid":"b320fd3c83007007ce2a620ef8930df4","version":"1.6.1","vendor":{"name":"The Apache Software Foundation","version":"1.6.1"}}
So I'm confident it's either a network issue or firewall issue.
This is what I did:
Centos 7 (AMI: ami-96a818fe)
Installed erlang and couchdb
yum update
Setup a firewall:
sudo yum install firewalld
sudo systemctl enable firewalld
sudo systemctl start firewalld
sudo firewall-cmd --get-active-zones (made sure we have public available)
sudo firewall-cmd --permanent --zone=public --add-service=ssh
sudo firewall-cmd --permanent --zone=public --add-port=5984/tcp
Implement changes:
sudo firewall-cmd --reload
Made sure it's all there:
sudo firewall-cmd --permanent --list-all
Created a security group opened to the world:
Type Protocol Port Range Source
All TCP TCP 0 - 65535 0.0.0.0/0
Anything else I am missing? Seems like Amazon is all set but why can't I hit this machine from the public IP for this port or internal IP on the machine for this port?
Thanks
I believe your --add-* commands are not taking immediate effect, due to the --perm options. The --reload may not pull in permanent changes. Try this again without --perm and see if the port actually opens:
sudo firewall-cmd --zone=public --add-port=5984/tcp
You usually want to experiment with commands like that, and then only add --permanent once you know they’re working as intended.
I am attempting to run pg_basebackup in order to create a slave server, but I keep getting this error:
pg_basebackup: could not connect to server: could not connect to server: No route to host
Is the server running on host "192.168.1.164" and accepting
TCP/IP connections on port 5432?
On the 192.168.1.164 server, the postgresql.conf file has:
listen_addresses = '*' # originally 'localhost, 192.168.1.63'
port = 5432
and the pg_hba.conf file has:
host replication replicator 192.168.1.63/32 md5
where 192.168.1.63 is the slave server.
The link between the two machines is fine since I can SSH from either one to the other using those IPs. Also, the service postgresql is started on the master, and stoped on the slave. The master has a Postgres user replicator.
I am running both machines with PostgreSQL 9.4.4 and Fedora 22.
EDIT: from the master's psql, running SHOW config_file; and SHOW hba_file; matches with the files I've been editing, and of course, the server was restarted after the edits.
It turns out this was a firewall issue. The solution is this:
firewall-cmd --permanent --add-port=5432/tcp
firewall-cmd --add-port=5432/tcp
Note: I came from Ubuntu which doesn't have this port blocked, so I didn't realize it needed to be opened up.