Host laptop:
VirtualBox VM with NAT Network Adapter:

If I run this it doesn't work if I open in the browser

ssh -L 30012: -N -f -l usersu

But this works perfectly fine:

ssh -L 30012: -N -f -l usersu

I also added the rule in UFW to allow 30012. What am I doing wrong?

I need to do this port forwarding from VirtualBox VM in which I do web site development. I wanted to check the web site using mobile device.

The VirtualBox VM has two network interfaces NAT and host only. For some reason Virtual Box NAT port forwarding stopped to work (Host and guest restart did not help). I decided to use SSH port forwarding. But it only works on

I know I could add 3rd network inteface "Bridged Adapter" in VirtualBox to get a new IP in local network but this solution I don't like because it introduces some complexity. is the host only network interface of VirtualBox VM. I can access it only from host and guest VMs, but not from mobile phone which is connected to the local network which is 192.168.0.x.

Tried to use this

ssh -L 30012: -N -f -l usersu

It works for, but doesn't work for

Based on the @JakeGould’s comment at the moment I use workaround in which I added 3rd Bridged Network interface and for webpack did this change as explained in this answer.

  • You normally cannot communicate with your local intranet address on the localhost. Why exactly are you against using localhost ( The formatting of your question makes your question hard to read. You should edit your question to clearly indicate which command is working. – Ramhound Apr 25 at 0:27
  • 1
    Most likely your application is set to only bind to localhost ( when if you want the application to network off of your device you need to bind to or even The would bind your application to any port on your machine where would only bind to that specific IP address. – JakeGould Apr 25 at 0:30
  • @JakeGould - Any port or any address? Wouldn’t be my address on a given port? (Whatever port SSH is set to) – Ramhound Apr 25 at 0:51
  • @Ramhound Binding a server to tells most applications: “Use any network interface on this machine and bind the application to that interface.” But when the user says they want to connect their app to the LAN, this idea might not work since LAN access would imply the host would need to be accessible on the LAN. This advice I posted would work for the guest. The real solution is to use “Bridged Mode” and allow the VM to be a part of the LAN despite the claims of “complexity” raised by the original poster. Bridged mode is the only real solution here. – JakeGould Apr 25 at 0:59
  • @user1325696 Did my comments solve your issue? – JakeGould Apr 25 at 1:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.