ODelibalta
ODelibalta

Reputation: 2254

Laravel Homestead - page stopped working ERR_ADDRESS_UNREACHABLE

Took my laptop out of house for a couple of days, didn't even get to turn it on during that time. Came back, ready to keep fiddling with my project but the page stopped working all of a sudden. I started getting ERR_ADDRESS_UNREACHABLE in the browser.

I've uninstalled homestead box, vagrant, virtualbox, with restart after each, re installed everything, same issue.

I can not ping the 192.168.10.10 address but I can SSH into the box no problem.

Running MacOS Big Sur, VirtualBox 6.1, Vagrant 2.2.18 and whatever the latest homestead version is. Really about quit programming altogether, this is super frustrating. I'd really appreciate any help. Thank you

Homestead.yaml

---
ip: "192.168.10.10"
memory: 2048
cpus: 2
provider: virtualbox

authorize: ~/.ssh/id_rsa.pub

keys:
    - ~/.ssh/id_rsa

folders:
    - map: ~/Documents/Code
      to: /home/vagrant/code

sites:
    - map: homestead.test
      to: /home/vagrant/code/PHP/test/public

databases:
    - homestead

features:
    - mysql: true
    - mariadb: false
    - postgresql: false
    - ohmyzsh: false
    - webdriver: false

services:
    - enabled:
          - "mysql"

Vagrantfile

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

require 'json'
require 'yaml'

VAGRANTFILE_API_VERSION ||= "2"
confDir = $confDir ||= File.expand_path(File.dirname(__FILE__))

homesteadYamlPath = confDir + "/Homestead.yaml"
homesteadJsonPath = confDir + "/Homestead.json"
afterScriptPath = confDir + "/after.sh"
customizationScriptPath = confDir + "/user-customizations.sh"
aliasesPath = confDir + "/aliases"

require File.expand_path(File.dirname(__FILE__) + '/scripts/homestead.rb')

Vagrant.require_version '>= 2.2.4'


Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
    if File.exist? aliasesPath then
        config.vm.provision "file", source: aliasesPath, destination: "/tmp/bash_aliases"
        config.vm.provision "handle_aliases", type: "shell" do |s|
            s.inline = "awk '{ sub(\"\r$\", \"\"); print }' /tmp/bash_aliases > /home/vagrant/.bash_aliases && chown vagrant:vagrant /home/vagrant/.bash_aliases"
        end
    end

    if File.exist? homesteadYamlPath then
        settings = YAML::load(File.read(homesteadYamlPath))
    elsif File.exist? homesteadJsonPath then
        settings = JSON::parse(File.read(homesteadJsonPath))
    else
        abort "Homestead settings file not found in #{confDir}"
    end

    Homestead.configure(config, settings)

    if File.exist? afterScriptPath then
        config.vm.provision "Run after.sh", type: "shell", path: afterScriptPath, privileged: false, keep_color: true
    end

    if File.exist? customizationScriptPath then
        config.vm.provision "Run customize script", type: "shell", path: customizationScriptPath, privileged: false, keep_color: true
    end

    if Vagrant.has_plugin?('vagrant-hostsupdater')
        config.hostsupdater.remove_on_suspend = false
        config.hostsupdater.aliases = settings['sites'].map { |site| site['map'] }
    elsif Vagrant.has_plugin?('vagrant-hostmanager')
        config.hostmanager.enabled = true
        config.hostmanager.manage_host = true
        config.hostmanager.aliases = settings['sites'].map { |site| site['map'] }
    elsif Vagrant.has_plugin?('vagrant-goodhosts')
        config.goodhosts.aliases = settings['sites'].map { |site| site['map'] }
    end

    if Vagrant.has_plugin?('vagrant-notify-forwarder')
        config.notify_forwarder.enable = true
    end
end

I did try to setup networking as described here and here but nothing worked. enter image description here

Upvotes: 4

Views: 1312

Answers (2)

ndberg
ndberg

Reputation: 4001

I think this is the fix, but I couldn't get it running until now:

Anything in the 192.68.56.0/21 range will work out-of-the-box without any custom configuration per VirtualBox's documentation.

https://github.com/laravel/homestead/issues/1717

Found some more related information here:

https://discuss.hashicorp.com/t/vagrant-2-2-18-osx-11-6-cannot-create-private-network/30984/16


update 29.10.2021:
I downgraded virtualbox to 6.1.26 and it's working again.

Upvotes: 3

ODelibalta
ODelibalta

Reputation: 2254

First of all, I really want to say a sincere thank you for all who looked at this and tried to help. I really appreciate it. @ndberg's post above turns out was half the answer. Following his link above, these are the steps I took to "resolve" this issue

ugh

step 1: 192.168.10.10 will not work on VBox 6.1.28, either change it to 192.168.56.** (i used 4 so its 192.168.56.4) and update your /etc/hosts file to match OR do none of that... and just create a /etc/vbox/networks.conf file and add * 192.168.10.0/24 to it. I went with updating existing files, I did not do the latter.

you are still not done

now the issue is Vagrant on the latest Monterey OS

step 2: open the Vagrantfile and add

config.vm.provider "virtualbox" do |v|
   v.gui = true
end

In default Vagrantfile that comes with Homestead, I added mine after the first if statement. This will open up the VM window on boot-up and you’d need to minimize/close that window. I am guessing we r waiting on an update from Vagrant to fix the issue

its working now though

with this comes the somewhat solid conclusion of my VirtualBox journey. Over the years, I've spent countless hours debugging various issues that came with using VirtualBoxes. Its time I try out docker containers instead.

thanks again everyone

Upvotes: 6

Related Questions