In a previous post is noted how to
restrict access to a Tomcat installation so that it could only be accessed from the local machine. Here is a little tip for how todo the same thing for PostgreSQL. This increases the security of these applications as you have to posses an account on the local machine to connect to the services.
The interfaces that PostgreSQL listens on is configured in a file called postgresql.conf which is often located in /etc/postgresql/ to restrict connections to PostgreSQL add the following line:
virtual_host = '127.0.0.1'
The restart PostgreSQL:
/etc/init.d/postgresql restart
You should then be able to check that PostgreSQL is only listening on the local interface with the command:
# netstat -tln | grep 5432
which should give you:
tcp 0 0 127.0.0.1:5432 0.0.0.0:* LISTEN