Private network IP, leave or edit for each new project?

After having a few sites up and running I started to get 404 not found error with production environments. I figured the issue was I was not declaring a unique local IP for each project.

Am I correct in thinking that each project should have a unique IP and the below should be adjusted, made unique for each project.

config.vm.network :private_network, ip: '192.168.50.5'

IE: If I have three projects each of the Vagrantfilefound in each would have unique IPs

  1. 192.168.50.5
  2. 192.168.50.10
  3. 192.168.50.15

If this is the case is there any insight to manage potential IP conflicts from other projects you may clone where an existing IP in the vagrantfile competes to one you’ve already used?

If I am not correct, then what would be causing the random 404 errors on production environments?

I believe you’re correct, that any time you have multiple vagrant VMs running in your development environment, you’ll need to edit the related vagrantfiles to have unique IPs (before vagrant up). There is some discussion here and at roots/trellis#295.

You won’t need to worry about IPs for VMs that are not running, assuming the vagrant-hostsupdater plugin succeeded in removing their IPs from your /etc/hosts on vagrant halt or vagrant destroy.

I’d love some kind of easy solution for dynamic IPs for vagrant VMs.

2 Likes

I ran into some issues even when I did halt the other VMs. At some point I think I had 4 projects with all the same IP and even though I only had the specific VM running it still gave me a 404. The error also seemed to be picky to 2 particular projects even though a few others worked fine with the same IP.

I don’t have that many projects that manually checking IPs is a big deal, however I was curious if there was a way that wasn’t manual.

Thanks for the clarity.

If you keep running into 404s, try this: Halt all VMs and remove VM-related entries from your /etc/hosts file, particularly entries similar to the example below. You may want to backup the hosts file before editing.

192.168.50.5  example.dev  # VAGRANT: 22c9...

Then vagrant up any VMs you need running and double-check that appropriate entries appear in your hosts file.

A tidy hosts file would reduce the likelihood of 404s, although it’s not a guarantee.

2 Likes

I did try that. Also followed some of the instructions supplied in this thread Vagrant intermittent.

I’ve since changed the IP and things are working again.