Super User is a question and answer site for computer enthusiasts and power users. 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 using Mac OS X 10.6. I have installed Virtual Box 4.1.0 in it. My Guest OS is Ubuntu Server 11.04. I have added a rule in Port Forwarding in Virtual Box ->

"guestssh" TCP 127.0.1.1 8080 127.0.0.1 1337

Inside Guest OS I'm running nodejs server. Code is nothing but simple helloworld code found on their site http://nodejs.org/. In short I'm running server on 127.0.0.1 on 1337 Port.

Now according to rule I have given, from Host Machine all the requests for 127.0.1.1:8080 should be forwarded to 127.0.0.1:1337 of Guest OS. From Host I'm doing curl http://127.0.1.1:8080 and I'm getting curl: (7) couldn't connect to host Is there something am I doing wrong?

Note- Don't give me suggestion to do ssh n all. As my ISP does not provide Internal LAN so its not possible in my case. All I can do it Port Forwarding.

share|improve this question
up vote 3 down vote accepted

I was having the same problem and took a tip from this answer: http://stackoverflow.com/a/6181230/1233020

Inside your virtualbox guest, run ifconfig or ip addr (depends on your linux distro). For arch linux (what I used) it's ip addr, the output is:

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN 
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
inet6 ::1/128 scope host 
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 08:00:27:75:e6:cc brd ff:ff:ff:ff:ff:ff
inet 10.0.2.15/24 brd 10.0.2.255 scope global eth0
inet6 fe80::a00:27ff:fe75:e6cc/64 scope link 
valid_lft forever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 08:00:27:8c:04:e6 brd ff:ff:ff:ff:ff:ff
inet 192.168.56.3/24 brd 192.168.56.255 scope global eth1
inet6 fe80::a00:27ff:fe8c:4e6/64 scope link 
valid_lft forever preferred_lft forever

This is the interesting line:

inet 10.0.2.15/24 brd 10.0.2.255 scope global eth0

I changed the port forwarding rule to use 10.0.2.15 and then everything worked! (you may need to restart your vm).

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .