Jekyll Blogging on Chromebooks

Chrome error message: This site can't be reached. 127.0.0.1 refused to connect.

The simple solution:

Tweak your jekyll serve command:

$ bundle exec jekyll serve --host $(hostname -I)

Then point Chrome to this address:

http://penguin.linux.test:4000

Why?

I’m glad you asked! This is a good opportunity to learn a bit more about how ChromeOS works under the hood.

Maybe you followed the Quickstart Jekyll Guide (or a similar routine) without any issues, but got stuck when trying to view the site in the Chrome browser.

By default, jekyll serve starts the server on 127.0.0.1:4000. However, the Chrome browser and the Linux Terminal are basically running on different machines. Chrome does not know about localhost on the Linux Terminal.

In order for the two to communicate with one another, we have to go through an acceptable channel. Ater Chrostini 69.0.3486.0 the following method for resolving Linux container hostnames was introduced for the browser. These follow the pattern:

<container_name>.<vm_name>.linux.test
<container_name>.linux.test

This means the problem can be solved by hosting the Jekyll server on a hostname and port the browser can listen on.

On my machine:

$ hostname
penguin
$ hostname -I
100.115.92.202

When we run jekyll serve on this host: --host $(hostname -I) and the default port, we can point the Chrome browser to http://penguin.linux.test:4000 and resolve to the Jekyll server!