A
A
at0m1x2015-12-24 14:02:06
Vagrant
at0m1x, 2015-12-24 14:02:06

Why is the forwarded port not working?

Using Vagrant, I set up a virtual machine with Ubuntu server and PHP.

Port forwarded:
host: '1234'
guest: '1144'

When starting vagrant (vagrant up) it says:

==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
    default: Adapter 2: hostonly
==> default: Forwarding ports...
    default: 22 => 8016 (adapter 1)
    default: 1144 => 1234 (adapter 1)
    default: 22 => 2222 (adapter 1)


I run the built-in PHP server on a virtual machine:
$ php -S 0.0.0.0:1144
PHP 5.5.29-1+deb.sury.org~trusty+3 Development Server started at Thu Dec 24 10:47:34 2015
Listening on http://0.0.0.0:1144
Document root is /home/vagrant
Press Ctrl-C to quit.


I'm trying to open on the host machine (i.e. the main OS that is on the computer, not a virtual machine) address: 127.0.0.1:1234
or
192.168.56.101:1234

It does not open, most likely I messed up with IP or ports, until I figured out what exactly .

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
at0m1x, 2015-12-24
@at0m1x

Found a solution, answering my own question.
1. The network setup in VirtualBox looks like this:
prntscr.com/9i3dld
2. We start the built-in PHP server on the virtual machine only under 0.0.0.0 IP, like this:
3. Open port 8081 on the virtual machine to the outside:
4. On the host machine (Windows) in the browser, specify the external IP address of the virtual machine and the port that we opened to the outside:
192.168.56.101:8081
After such "not tricky" :) manipulations it worked.

D
Damir Makhmutov, 2015-12-24
@doodoo

Try starting the server like this:php -S localhost:1144

O
Omich, 2015-12-24
@omichkun

Check the Windows firewall (do you have Windows on the main machine?), all firewalls and antiviruses. I have the same problem at work and the problem turned out to be that Casper was blocking "unnecessary" ports, in his opinion.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question