Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to connect to a PostgreSQL database hosted on a Win7 guest from a Win7 host.

I've configured security in pg_hba.conf

host    all         all          md5
host    all         all          md5
host    all         all        md5

and set the listen_addresses setting in postgresql.conf to '*'.

I think I've set up port forwarding correctly as I see:

Key: VBoxInternal/Devices/e1000/0/LUN#0/Config/win7_vm1/GuestPort, Value: 5432
Key: VBoxInternal/Devices/e1000/0/LUN#0/Config/win7_vm1/HostPort, Value: 5432
Key: VBoxInternal/Devices/e1000/0/LUN#0/Config/win7_vm1/Protocol, Value: TCP

when I call getextradata.

This is similar to but I'm not sure what I'm doing wrong.

In the vbox.log file I see:

00:00:01.019 NAT: set redirect TCP host port 5432 => guest port 5432 @ 00:00:01.033 NAT: failed to redirect TCP 5432 => 5432

but I'm not sure how to fix that. Any ideas? Thanks.

share|improve this question

My first question would be, can you verify that you can connect to PostgreSQL on the guest from the guest?

As for the issue with the port forwarding failure, that is typically the result of VirtualBox not being able to create a socket listening for connections on the host - and the most common cause for that is that something else is already listening on that port. Do you have a PostgreSQL running on the host as well?

Take a look at the TCPView tool from the SysInternals team at Microsoft. It can show you active TCP endpoints and their owning process. This should help you determine if something has grabbed TCP 5432 and what it is. Run it on the host - and guest if you want to verify PostgreSQL is running and listening for connections.


share|improve this answer

If the database is hosted on the host, then no port forwarding should be needed, just point the guest to the NAT host (identified via ipconfig).

share|improve this answer
sorry, i should've been more clear...the database is hosted on the guest. – kliao Aug 3 '10 at 1:37
You are probably better off running the guest on a bridged NIC as each NATed NIC/network shares the same IPs. – user48838 Aug 3 '10 at 1:58

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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