Dutchman08
Dutchman08

Reputation: 15

Cannot access vagrant vm from the host machine

I've set a vagrant virtual box with Puphpet which is running fine (in Ubuntu 14.04) and I'm able to connect to it via ssh. I've also used vagrant hostmanager to get the vm's IP automatically added to the hosts file.

This is the hosts file:

127.0.0.1   localhost
127.0.1.1   pcuser-HP-EliteBook-8470p

# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters


## vagrant-hostmanager-start id: 2314dd30-24cf-4122-8779-8b755f5e6186
172.22.22.22    projectname.local
172.22.22.22    www.projectname.local
## vagrant-hostmanager-end

## vagrant-hostmanager-start id: c20d4d7f-3ada-4b2a-b142-e44826571754
192.168.56.101  machine1.puphpet
192.168.56.101  symfony.dev
## vagrant-hostmanager-end

The problem is when I try to access the VM from the host either through the IP address or through the virtual host server name I've set (symfony.dev).

Either time it's unable to connect to it, although I've pinged the machine IP from the host and it's responding fine.

At first I didn't have the vagrant hostmanager installed and just added the IP and the virtual host server name (symfony.dev) manually to the hosts file but it wasn't able to connect.

I've checked the settings in config.yaml file and they all seem to be fine:

vagrantfile:
target: local
vm:
    provider:
        local:
            box: puphpet/ubuntu1404-x64
            box_url: puphpet/ubuntu1404-x64
            box_version: '0'
            chosen_virtualizer: virtualbox
            virtualizers:
                virtualbox:
                    modifyvm:
                        natdnshostresolver1: false
                    showgui: 0
                vmware:
                    numvcpus: 1
                parallels:
                    linked_clone: 0
                    check_guest_tools: 0
                    update_guest_tools: 0
            machines:
                vflm_zaw8al7jczu3:
                    id: machine1
                    hostname: machine1.puphpet
                    network:
                        private_network: 192.168.56.101
                        forwarded_port:
                            vflmnfp_67om22p4f0j3:
                                host: '5608'
                                guest: '22'
                    memory: '1024'
                    cpus: '1'
    provision:
        puppet:
            manifests_path: puphpet/puppet/manifests
            module_path:
                - puphpet/puppet/modules
                - puphpet/puppet/manifests
            options:
                - '--verbose'
                - '--hiera_config /vagrant/puphpet/puppet/hiera.yaml'
    synced_folder:
        vflsf_y5mnuhi3ihqh:
            source: ./
            target: /var/www
            sync_type: nfs
            smb:
                smb_host: ''
                smb_username: ''
                smb_password: ''
                mount_options:
                    dir_mode: '0775'
                    file_mode: '0664'
            rsync:
                args:
                    - '--verbose'
                    - '--archive'
                    - '-z'
                exclude:
                    - .vagrant/
                    - .git/
                auto: 'true'
            owner: www-data
            group: www-data
    usable_port_range:
        start: 10200
        stop: 10500
    post_up_message: ''

Do I need to change anything in the configuration or what am I missing or doing wrong?

Any help is greatly appreciated.

Upvotes: 0

Views: 1636

Answers (2)

Dutchman08
Dutchman08

Reputation: 15

It works fine now. In the end I found out that it was a problem with the PuphPet package that I have installed. I discovered that apache was not installed on the virtual machine, although I have selected it in the package build on Puphpet GUI and it also appeared to be installed as per the config.yaml file.

Merci pour ton aide, Frederic Henri!

Upvotes: 0

Frederic Henri
Frederic Henri

Reputation: 53703

you start your server but its bound to 127.0.0.1 / localhost IP so its only accessible from the VM

you need to start it using the IP of the VM or the 0.0.0.0 IP. something like this should work

php bin/console server:start 0.0.0.0:8000

Upvotes: 1

Related Questions