1

I created a Vagrant machine with an ubuntu 14.04 (vagrant file below).

I forwarded host port 8080 to guest port 8000.

I have a symfony project on host (Vagrant file folder) (just a symfony new myproject built).

I ssh to guest machine and execute php app/console server:run (web server is up) on /vagrant folder

I try to acces localhost:8080 from a host browser and I have no answer.

How can I access to symfony web server from host machine?

I simplified at max level my vagrant and provision files for easy readability.

This is my vagrant file:

# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure(2) do |config|
  config.vm.box = "ubuntu/trusty64"
  config.vm.network "forwarded_port", guest: 8000, host: 8080
  config.vm.network "private_network", ip: "10.10.10.10"      
  config.vm.provision "shell", path: "provision.sh"
end

provision.sh file:

#!/usr/bin/env bash
apt-get update > /dev/null
apt-get install --assume-yes php5-cli

when I do nmap localhost on guest machine:

Starting Nmap 6.40 ( http://nmap.org ) at 2015-10-28 09:04 UTC
Nmap scan report for localhost (127.0.0.1)
Host is up (0.00020s latency).
Not shown: 996 closed ports
PORT     STATE SERVICE
22/tcp   open  ssh
111/tcp  open  rpcbind
5432/tcp open  postgresql
8000/tcp open  http-alt

Thanks a lot!

Jordi

6
  • Have you tried http://10.10.10.10:8080 (your private network ip and external port)? Commented Oct 28, 2015 at 10:13
  • 1
    "I forwarded host port 8080 to guest port 8000.", that pretty much answers your question. You should open localhost:8000, since you forwarded it to local port 8000 and not 8080. Commented Oct 28, 2015 at 10:13
  • @qooplmao Yes, I tryed but were no answer :-( Commented Oct 28, 2015 at 10:56
  • @Oldskool I also tried forward 8000 to 8000 and It didn't work. If you make vagrant init, you have a vagrant file with a port forwading example, it says: # Create a forwarded port mapping which allows access to a specific port # within the machine from a port on the host machine. In the example below, # accessing "localhost:8080" will access port 80 on the guest machine. # config.vm.network "forwarded_port", guest: 80, host: 8080 It let me think when you browse from host to localhost:8080, http request is received on guest machine at 80 (or 8000 as I modify this example) :-S Commented Oct 28, 2015 at 11:00
  • 1
    Is the server listening to the correct ip/port? Have you tried running the server using php app/console server:start 0.0.0.0:8000? Commented Oct 28, 2015 at 11:03

2 Answers 2

5

Thanks to @qooplmao for this answer.

I create an answer because maybe it will be easier to find for another with similar problem.

The problem is that symfony server launched with app/console server:run just heard from 127.0.0.1 requests.

To solve this, @qooplmao tell me we can launch symfony web server for all ip.

Just doing: app/console server:start 0.0.0.0:8000 Oh! If you want to stop it, you have to app/console server:stop 0.0.0.0:8000

Thanks again for your help!

Sign up to request clarification or add additional context in comments.

Comments

1

in symfony3 you need to use this:

cd project directory
php bin/console server:run 0.0.0.0:8000

and stop server with pressing ctrl + c

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.