Flawless vagrant up but Unable to connect to trellis.local in browser

Sorry for a lengthy post. I’ve been stuck here for about 9 days.

Result of successful vagrant up --provision

The command vagrant up --provision was successful. I copied the output to a gist,
–>linked here.

However, whenever I try to access the domain, http://trellis.local, I get “Unable to connect” in both FireFox and Chrome.

Versions

  • Windows Version 10.0.18363 Build 18363
  • WSL 1 running Ubuntu
  • On WSL, ansible --version = 2.8.0 (also matches in vagrant.default.yml)
  • vagrant 2.2.9 on both Windows and WSL.
  • VirtualBox GUI Version 6.1.14 r140239 (Qt5.6.2)

Let me know if I missed something.

Troubleshooting

  1. Is site key trellis.local the key for both vault.yml and wordpress_sites.yml? Is there a canonical listed?
    Yes, and Yes, everything is trellis.local.

  2. What does /etc/hosts look like?
    Here is the full cat /etc/hosts output. Snippet:

127.0.1.1       trellis.local   trellis
## vagrant-hostmanager-start
192.168.50.5    trellis.local
192.168.50.5    www.trellis.local
## vagrant-hostmanager-end
  1. Can you ping trellis.local? How about 192.168.50.5?
    Yes, here’s the result.

  2. Can you run vagrant ssh?
    Yes.

  3. Do you even have a bedrock site installed?
    Yes,

vagrant@trellis:/srv/www/trellis.local/current$ ls
CHANGELOG.md  composer.json  composer.lock  config  LICENSE.md  phpcs.xml  README.md  vendor  web  wp-cli.yml
  1. Is nginx running?
    Yes, Active: active (running) since Thu 2020-09-24 17:19:34 UTC; 9min ago
    but there appears to be an error.
    Sep 24 17:19:34 trellis systemd[1]: nginx.service: Can't open PID file /var/run/nginx.pid (yet?) after start: No such fi
    Here is the full output of sudo nginx service status.

  2. Is MariaDB running?
    Yes, here’s the receipt.

  3. (out of desperation) Does the adapter used by VirtualBox for your Vagrant box show the same IPv4 address as vagrant-default.yml: 192.168.50.5?
    Yes…
    VirtualBox is using two adapters, one is NAT, the other is Host-Only Ethernet Adapter #2. To check IPv4 address for Ethernet Adapter #2, go to Control Panel > Network and Internet > Network and Sharing Center > Change adapter settings. Hover over each of the Ethernet adapters until you find the name of the one being used by VirtualBox. Right-click on the adapter > Properties > Double-click on Internet Protocol Version 4 (TCP/IPv4) -> Shows 192.168.50.5.

  4. Does .bashrc allow WSL and Windows to “talk” to each other about VirtualBox?
    Yes, I followed these instructions in the docs, replacing /mnt/c with /mnt/e to reflect VirtualBox installation path.

Next Steps

  • First, I’m going to look into the nginx error in point 4 above.
  • If that doesn’t work, I’ll look into something-something disable Windows firewall.

I’ve already tried starting fresh a couple times, with the same result each time.

Edit: By starting fresh, I mean re-cloning roots/trellis, not the example project.

However, at this point… Does anyone have any tips, please?

What are the contents of Windows’ hosts file? The one you posted looks like it’s the WSL hosts file.

Aha…

C:\Windows\System32\drivers\etc\hosts

# localhost name resolution is handled within DNS itself.
#	127.0.0.1       localhost
#	::1             localhost
	127.0.0.1	mvc.localhost
	127.0.0.1	my-reveal-js-project.localhost

# trellis
	127.0.0.1	trellis.local

I’m betting this needs to point to your VM’s IP…? My recollection of doing dev on WSL was that the VMs aren’t really happening “in” WSL, because it’s not capable of turduckening virtualization layers like that, so WSL is just communicating w/ VirtualBox in your Windows environment. In which case I think you’d have to point Windows DNS to the correct IP. It’s been a while though, I could be mistaken.

betting this needs to point to your VM’s IP…?

Let’s try it.

  1. vagrant halt
  2. copy/edit/overwrite C:\Windows\System32\drivers\etc\hosts to 192.168.50.5 trellis.local
  3. restart computer.
  4. trellis > vagrant up --provision (here’s the full output)
  5. cat /etc/hosts on WSL just to check that it updated to 192.168.50.5 → it did.
  6. Try http://trellis.local → sends me to https://trellis.local and says “Unable to connect”.

Other random troubleshooting,
Windows Firewall
I temporarily turned off Windows Firewalls, which had no effect: still “Unable to connect”.

/srv/www/trellis.local/logs
All I got is access.log

127.0.0.1 - - [24/Sep/2020:06:14:25 +0000] "GET /2020/09/24/hello-world/ HTTP/1.1" 200 9999 "http://trellis.local/2020/09/24/hello-world/" "WordPress/5.5.1; http://trellis.local" "-"

At this point, I’m willing to try updating Windows to the latest build, which allows for WSL2 instead of WSL1. I expect to report back in a few days if this makes any difference.

IIRC WSL2 is incompatible (mostly) with VirtualBox because WSL2 requires Hyper-V which doesn’t work very well with VirtualBox VMs.

WSL2 is incompatible (mostly) with VirtualBox

Yeahh, I had the same result as DreamOn when trying to use Trellis out the box with WS2.

I destroyed my first Ubuntu distribution, then installed a new Ubuntu 18.04 dist, making sure to set it to WSL1.

With a Trellis project on a fresh distro, running vagrant up appeared to start up just fine.

Now the vagrant IP address and (http://)trellis.local results in “The connection has timed out”, instead of “Unable to connect”.

I’ll check on the access and error logs on the machine after taking a couple days break. :sleeping:

You need to check hosts file in Windows 10 and WSL.

Windows 10: C:\Windows\System32\drivers\etc\HOSTS
WSL (Ubuntu): /etc/hosts

Check if IP and hosts are the same

This topic was automatically closed after 42 days. New replies are no longer allowed.