Roots Discourse

Can't access roots-example-project from Host

hi, I have set up my local development environment using Getting Started Docs for Windows.

My issue: can’t access my site from the Host.
https://roots-example-project.test/ does not load.

My findigs so far:

  • Website is up and running inside WSL:
    lynx roots-example-project.test warns “SSL error:The certificate is NOT trusted” but loads the page (all inside WSL).
    image
    image

  • I can ping my website IP from the host by IP:
    PS C:\WINDOWS\system32> ping 192.168.50.5
    Pinging 192.168.50.5 with 32 bytes of data:
    Reply from 192.168.50.5: bytes=32 time<1ms TTL=64
    Reply from 192.168.50.5: bytes=32 time<1ms TTL=64
    Reply from 192.168.50.5: bytes=32 time<1ms TTL=64

  • I can’t ping by hostname from the host:
    PS C:\WINDOWS\system32> ping roots-example-project.test
    Ping request could not find host roots-example-project.test. Please check the name and try again.

  • nginx is up, I can see my lynx sessions
    kpoxo6op@DESKTOP-LR23FLP:/mnt/c/temp/Sites/roots-example-project.com/trellis$ vagrant ssh
    vagrant@roots-example-project:/srv/www/roots-example-project.com/logs$ cat access.log
    192.168.50.1 - - [14/Oct/2019:06:55:48 +0000] “GET / HTTP/1.0” 200 15591 “-” “Lynx/2.8.9dev.16 libwww-FM/2.14 SSL-MM/1.4.1 GNUTLS/3.5.17” “-”
    192.168.50.1 - - [14/Oct/2019:07:22:40 +0000] “GET / HTTP/1.0” 200 15591 “-” “Lynx/2.8.9dev.16 libwww-FM/2.14 SSL-MM/1.4.1 GNUTLS/3.5.17” “-”

  • I can access website from my host through browsersync

image

more Information -
here is my hosts file at WSL:

vagrant@roots-example-project:/srv/www/roots-example-project.com/logs$ cat /etc/hosts
127.0.0.1       localhost
127.0.1.1       roots-example-project.test      roots-example-project

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

## vagrant-hostmanager-start
192.168.50.5    roots-example-project.test
192.168.50.5    www.roots-example-project.test
## vagrant-hostmanager-end

Windows hosts file:

# localhost name resolution is handled within DNS itself.
#	127.0.0.1       localhost
#	::1             localhost

# Added by Docker for Windows
192.168.1.5 host.docker.internal
192.168.1.5 gateway.docker.internal
# End of section

vagrant ssh output

Welcome to Ubuntu 18.04.2 LTS (GNU/Linux 4.15.0-51-generic x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

  System information as of Mon Oct 14 07:42:52 UTC 2019

  System load:  0.0               Processes:           99
  Usage of /:   3.6% of 61.80GB   Users logged in:     0
  Memory usage: 30%               IP address for eth0: 10.0.2.15
  Swap usage:   0%                IP address for eth1: 192.168.50.5

115 packages can be updated.
61 updates are security updates.

Your windows hosts file needs to point your domain to the IP of your VM.

1 Like

thanks, I’ll try it out.
Is hosts entry such a ‘common sense’ thing it’s not there in guides? Is there some guide for local development explaining this stuff?

The Vagrantfile in Trellis includes some plugins that are meant to change the hosts entries for you, but in a Windows or Windows/WSL environment my success with them has ranged from “mixed” to “none.” In Linux or MacOS they’re much more reliable.

How to manipulate the hosts file, why to manipulate it, and what it does is would probably be considered “common knowledge” for the sorts of folks who are going to be comfortable with Trellis. The Roots stack is intended to be a collection of best practices that help you improve and do things in a good way, but it’s not intended to be a beginner stack, nor is it built with the intention of holding your hand throughout the whole process.

2 Likes

thanks for your help, hosts entry fixed it, I can access my site from Host now.
Also, my deployment to Digital Ocean droplet worked as well! Trellis is pretty impressive I must say :grinning: