I am trying to open port 5432 on ubuntu using ufw using sudo ufw allow 5432/tcp

I then use nmap to see if port 5432 was opened and i get this:

root@domain:~# sudo nmap -sS -O 127.0.0.1

Starting Nmap 5.21 ( http://nmap.org ) at 2011-12-01 14:28 MSK
Nmap scan report for localhost.localdomain (127.0.0.1)
Host is up (0.000084s latency).
Not shown: 994 closed ports
PORT      STATE SERVICE
22/tcp    open  ssh
25/tcp    open  smtp
80/tcp    open  http
587/tcp   open  submission
5432/tcp  open  postgresql
10000/tcp open  snet-sensor-mgmt
Device type: general purpose
Running: Linux 2.6.X
OS details: Linux 2.6.15 - 2.6.30
Network Distance: 0 hops

OS detection performed. Please report any incorrect results at http://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 2.28 seconds


root@domain:~# sudo nmap -sS -O 1xx.xxx.xxx.xxx

Starting Nmap 5.21 ( http://nmap.org ) at 2011-12-01 14:30 MSK
Nmap scan report for domain.info (1xx.xxx.xxx.xxx)
Host is up (0.000086s latency).
Not shown: 997 closed ports
PORT      STATE SERVICE
22/tcp    open  ssh
80/tcp    open  http
10000/tcp open  snet-sensor-mgmt
Device type: general purpose
Running: Linux 2.6.X
OS details: Linux 2.6.15 - 2.6.30
Network Distance: 0 hops

OS detection performed. Please report any incorrect results at http://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 2.65 seconds

1xx.xxx.xxx.xxx is the ip of my server.

link|improve this question
feedback

2 Answers

up vote 1 down vote accepted

You need to edit your pg_hba.conf:

host all all 192.168.0.0/24 trust

This allows every from the 192.168.0.0/24 network to connect. A wild-card for all would be 0.0.0.0/0. More information here.

Then edit postgresql.conf and change listen_address:

listen_addresses='*'
link|improve this answer
Yes, need to cover the scenerio where it is postgres itself that is blocking the connection rather than the firewall... – djangofan Dec 1 '11 at 20:19
I am looking for postgres logs to see if that's the case. – boot-baby-boot Dec 2 '11 at 9:09
Finally got it.Thanks till and to everyone trying it,remember '#' means a comment. – boot-baby-boot Dec 3 '11 at 15:10
feedback

I have edited pg_hba.conf:

# DO NOT DISABLE!
# If you change this first entry you will need to make sure that the
# database
# super user can access the database using some other method.
# Noninteractive
# access to all databases is required during automatic maintenance
# (custom daily cronjobs, replication, and similar tasks).
#
# Database administrative login by UNIX sockets
local   all         postgres                          ident

# TYPE  DATABASE    USER        CIDR-ADDRESS          METHOD

# "local" is for Unix domain socket connections only
local   all         all                               ident
# IPv4 local connections:
host    all         all         0.0.0.0/0          md5
# IPv6 local connections:
host    all         all         ::1/128               md5

but port 5432 has not been opened.

link|improve this answer
Did you change listen_addresses as I adviced? – Till Dec 2 '11 at 1:52
Finally fixed it,i over looked the # the entire time.Shameful on my part. – boot-baby-boot Dec 3 '11 at 15:12
At least it's working! Happy to help! – Till Dec 3 '11 at 17:04
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.