Network fixes

Point a domain at your own machine (hosts file)

Make a name like myapp.test open your local app, by adding a line to the hosts file.

Fill these in once
  1. Add the lineNeeds sudo
    Terminal
    echo "127.0.0.1 myapp.test" | sudo tee -a /etc/hosts
  2. Make your Mac notice the changeNeeds sudo
    Terminal
    sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder

Check it worked

  1. Check the name points to the right place
    Terminal
    ping -c 1 myapp.test
Undo it
  1. Remove the lineNeeds sudo
    Terminal
    sudo sed -i '' '/ myapp.test$/d' /etc/hosts
  1. Add the lineNeeds sudo
    Terminal · Ubuntu / Debian
    echo "127.0.0.1 myapp.test" | sudo tee -a /etc/hosts

Check it worked

  1. Check the name points to the right place
    Terminal · Ubuntu / Debian
    getent hosts myapp.test
Undo it
  1. Remove the lineNeeds sudo
    Terminal · Ubuntu / Debian
    sudo sed -i '/ myapp.test$/d' /etc/hosts
  1. Add the lineRun as administrator
    PowerShell
    Add-Content -Path "$env:windir\System32\drivers\etc\hosts" -Value "127.0.0.1 myapp.test"
  2. Make Windows notice the change
    PowerShell
    ipconfig /flushdns

Check it worked

  1. Check the name points to the right place
    PowerShell
    Resolve-DnsName myapp.test
Undo it
  1. Remove the lineRun as administrator
    PowerShell
    (Get-Content "$env:windir\System32\drivers\etc\hosts") | Where-Object { $_ -notmatch ' myapp.test$' } | Set-Content "$env:windir\System32\drivers\etc\hosts"

New to DNS? I explain it in plain English on Layman Terms.