Wednesday, September 27, 2023
 Popular · Latest · Hot · Upcoming
rated 0 times [  4] [ 0]  / answers: 1 / hits: 17295  / 2 Years ago, tue, august 3, 2021, 7:23:01

I've been struggling to open the port 5432 for remote PostgreSQL access. Which I installed on a Ubuntu 10.04 desktop machine.

Here is the shell log:

xybrek@ubuntu:~$ sudo ufw allow 5432
[sudo] password for xybrek:
Skipping adding existing rule
xybrek@ubuntu:~$ sudo ufw allow 5432/tcp
Skipping adding existing rule
xybrek@ubuntu:~$ sudo ufw status
Status: active

To Action From
-- ------ ----
5432/tcp ALLOW Anywhere
5433/tcp ALLOW Anywhere
5432 ALLOW Anywhere

5432/tcp ALLOW OUT Anywhere

xybrek@ubuntu:~$ sudo nmap localhost -p5432

Starting Nmap 5.00 ( ) at 2013-05-28 17:57 PHT
Warning: Hostname localhost resolves to 2 IPs. Using
Interesting ports on localhost (
5432/tcp closed postgresql

Nmap done: 1 IP address (1 host up) scanned in 0.12 seconds

When I try to connect to the port from another machine its just connection timeout, whereas when I try to connect to other port like 80, 8080 it works. What am I missing?


Status: active

To Action From
-- ------ ----
[ 1] 5432 ALLOW IN Anywhere

More From » networking


You have allowed OUT only on that port. So its considered closed as ou haven't allowed in. The 5432 rule is ignored as the 5432 OUT takes precedence.

To fix it best delete what you have and add rule again.

List the rules with the following command

sudo ufw status numbered

then delete the rule by the line number

 sudo ufw delete X

Where X is the rule that has the 5432 against it. Repeat to delete other rule as well, make sure you do the status numbered command again to see the new numbers as when you delete one the numbers change

Then add the rule properly with command

sudo ufw allow 5432

[#31005] Thursday, August 5, 2021, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.

Total Points: 24
Total Questions: 105
Total Answers: 109

Location: Western Sahara
Member since Tue, Feb 16, 2021
3 Years ago