I bought a VPS from DigitalOcean with applications Rails+Unicorn+Nginx. I installed Postgresql 9.1 and trying to accept remote connections from that. I read all of the solutions/problems about it (Googled much) and did exactly. The problem is the following:
psql: could not connect to server: Connection refused
Is the server running on host "xxx.xxx.xxx.xxx" and accepting
TCP/IP connections on port 5432?
I edited the postgresql.conf file with listen_addresses='*'
I edited the pg_hba.conf file and added host all all 0.0.0.0/0 md5
I restarted postgresql service and even the VPS however still I cannot connected to the database. So I tried to check the server's listening ports:
netstat -an | grep 5432
tcp 0 0 127.0.0.1:5432 0.0.0.0:* LISTEN
unix 2 [ ACC ] STREAM LISTENING 8356 /tmp/.s.PGSQL.5432
and then I nmap'ed the server:
Not shown: 996 closed ports
PORT STATE SERVICE
21/tcp open ftp
22/tcp open ssh
80/tcp open http
554/tcp open rtsp
But still I cannot understand why postgresql not serving at the port 5432 after the configurations. Need advice.
Thanks.
Related
My docker postgres instance can't be connected to from the internet.
I think it is because it is mapped by docker to localhost.
root#VM01:~/docker# docker port postgres
5432/tcp -> 127.0.0.1:5432
I am new to docker and I would like to try remapping that to
5432/tcp -> 0.0.0.0:5432
To see if I can then connect remotely over the internet.
root#VM01:~/docker# netstat -na | grep 5432
tcp 0 0 127.0.0.1:5432 0.0.0.0:* LISTEN
Does anyone have experience doing this or advice on if this might work...?
I have another docker instance on the same host that reflects 0.0.0.0:8000 and using telnet from any machine on the internet shows it is accessible.
Not this one though:
127.0.0.1:5432->5432/tcp
Running 2VMs by Vagrant within the private network like:
host1: 192.168.1.1/24
host2: 192.168.1.2/24
In host1, the app listens port 6443. But cannot access in host2:
# host1
root#host1:~# ss -lntp | grep 6443
LISTEN 0 4096 *:6443 *:* users:(("kube-apiserver",pid=10537,fd=7))
# host2
root#host2:~# nc -zv -w 3 192.168.1.2 6443
nc: connect to 192.168.1.2 port 6443 (tcp) failed: Connection refused
(Actually, the app is the "kube-apiserver" and fail to join the host2 as a worker node with kubeadm)
What am I missed?
Both are ubuntu focal (box_version '20220215.1.0') and ufw are inactivated.
After change the IP of hosts, it works:
host1: 192.168.1.1/24 -> 192.168.1.2/24
host2: 192.168.1.2/24 -> 192.168.1.3/24
I guess it is caused by using the reserved IP as the gateway, the first IP of the subnet, 192.168.1.1.
I'll update the references about that here later, I have to setup the k8s cluster for now.
I have PostgreSQL 13 installed on a server running Debian 10 Server. When I want to connect my PostgreSQL server, I should connect on port 5433, because my postgresql.conf file is like this:
# - Connection Settings -
listen_addresses = '*'
port = 5433
max_connections = 100
unix_socket_directories = '/var/run/postgresql'
But along with this port, I can connect on port 5432. While there is no any config file in my /etc/postgresql/13/main directory that contains port 5432. In addition, netstat -na outputs is like this:
For port 5432:
tcp 0 0 127.0.0.1:5432 0.0.0.0:* LISTEN
tcp6 0 0 ::1:5432 :::* LISTEN
unix 2 [ ACC ] STREAM LISTENING 27587 /var/run/postgresql/.s.PGSQL.5432
For port 5433:
tcp 0 0 0.0.0.0:5433 0.0.0.0:* LISTEN
tcp 164 0 192.168.1.100:42766 192.168.1.100:5433 CLOSE_WAIT
tcp 164 0 192.168.1.100:42782 192.168.1.100:5433 CLOSE_WAIT
tcp6 0 0 :::5433 :::* LISTEN
unix 2 [ ACC ] STREAM LISTENING 27607 /var/run/postgresql/.s.PGSQL.5433
That is so amazing that I have two different databases on two different ports, When I run psql command on 5432 and 5433 ports. I can connect from remote machine on port 5433, but I cannot connect on port 5432 from remote machine and just connect locally.
I want to know where is the port 5432 config and How I change it for remote machine connection?
I have an error with PostgreSQL:
SQLSTATE[08006] [7] could not connect to server: Connection refused
Is the server running on host "localhost" (::1) and
accepting TCP/IP connections on port 5432? could not connect to server: Connection refused
Is the server running on host "localhost" (127.0.0.1) and accepting TCP/IP connections on port 5432?
The following command doesn't show 5432 port is open:
sudo netstat -plunt |grep postgres
I guess that the problem is 5432 port so as I don't see it at netstat. How to open port for PostgreSQL?
The postgresql.conf and pg_hba.conf files are okay (see below).
postgres server is running
My postgresql.conf file:
listen_addresses = '*'
port = 5432
My pg_hba.conf file:
local all postgres md5
local all all md5
host all all 0.0.0.0/0 trust
host all all 127.0.0.1/32 trust
host all all ::1/128 trust
local replication all peer
host replication all 127.0.0.1/32 md5
host replication all ::1/128 md5
I ran the command: $ netstat -atu
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 localhost:6379 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:http 0.0.0.0:* LISTEN
tcp 0 0 localhost:domain 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:ssh 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:https 0.0.0.0:* LISTEN
tcp 0 0 30secondboomer.com:ssh 109-252-90-59.nat:11807 ESTABLISHED
tcp 0 0 30secondboomer.com:ssh 109-252-90-59.nat:11258 ESTABLISHED
tcp 0 0 30secondboomer.com:ssh 109-252-90-59.nat:11797 ESTABLISHED
tcp6 0 0 localhost:6379 [::]:* LISTEN
tcp6 0 0 [::]:http [::]:* LISTEN
tcp6 0 0 [::]:ssh [::]:* LISTEN
tcp6 0 0 [::]:https [::]:* LISTEN
udp 0 0 localhost:domain 0.0.0.0:*
udp 0 0 30secondboomer.c:bootpc 0.0.0.0:*
Got a similar error while settings up PostgreSQL to work with a Python/Django project.
Try to stop and restart the server again.
If indeed the challenge is port 5432 as you suspect, you can try to start postgres on another port say 5433 and see what happens.
For those, whose database server is not running at all, this solution worked for me, after reading the official PostgreSQL-9.6.16 documentation.
In your pg_hba.conf, you have :
host all all 127.0.0.1/32 trust
But this should probably contain the actual IP address of the machine from which the requests are coming (even if it is localhost, it should still contain the remote IP address as a connection from another machine would refer to it.
the following command:
sudo -u postgres pg_basebackup -h master-ip -D /var/lib/postgresql/9.3/main -U rep -v -P -x
is returning the following error
pg_basebackup: could not connect to server: could not connect to server: Connection refused
Is the server running on host "master-ip" and accepting
TCP/IP connections on port 5432?
notwithstanding the master EC2 instance has the following rule:
Custom TCP Rule TCP 5432 slave-ip/32
and the master's /etc/postgresql/9.3/main/pg_hba.conf file includes:
host all all 127.0.0.1/32 md5
host all ubuntu master-ip/32 trust
host all ubuntu slave-ip/32 md5
host all postgres slave-ip/32 md5
host replication replicator slave-ip/32 md5
Both master and slave instances are EC2 instances, but created from different accounts.
What is wrong here?