Search code examples
httpvagrantportforwardingngrok

Can't connect Ngrok with Vagrant


I'm using the "Scotchbox" (scotchbox.io) Vagrant file and I would like to use it together with Ngrok to demo work in progress for clients. I'm not really sure how to set this up properly with custom dev domains - such as "project.dev" - could anyone point me in the right direction here? Would be much appreciated.

My Ngrok file has no configuration added so far other than an authentication token, and my Vagrant file contains this -

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

Vagrant.configure("2") do |config|

  config.vm.box = "scotch/box"
  config.vm.network "private_network", ip: "192.168.33.10"
  config.vm.hostname = "scotchbox"
  config.vm.synced_folder ".", "/var/www", :mount_options => ["dmode=777", "fmode=666"]
  config.foodshow.enabled = true

end

Solution

  • You should edit your host file from your host machine.

    • on mac/linux, file is /etc/hosts
    • on windows, files C:\Windows\System32\Drivers\etc\hosts

    Add a line like

    192.168.33.10 project.dev www.project.dev
    

    There are others possibilities like using the vagrant host-manager which can manage this file automatically for you based on some settings from the Vagrantfile, but the idea remains the same.