Fastpages local dev on WSL2 - server refused to connect

Has anyone else run into this issue?

Setup:

  • Windows 10 Enterprise v1909
  • Ubuntu 20.04.1 LTS
  • Docker 2.5.0.1 stable

Steps to replicate:

  1. Clone GitHub repo into WSL2
  2. Run make server command
  3. Attempt to connect to 127.0.0.1:4000 in Windows Chrome browser
  4. Result: “host refused to connect”

Any ideas out there as to how I might be able to preview my fastpages build served from WSL2 via my Windows browser?

Note: This problem does NOT occur when running jupyter notebook on it’s own, but the jupyter server run via the Makefile from the fastpages template also refuses to connect.

SOLUTION: sudo apt-get install build-essential

Apparently, these “essential” libs were not installed by default in the WSL Ubuntu 20.04 distro…

Now everything works.

1 Like

Thanks for sharing

Hey @neuradai and @hamelsmu, hope you’re well :slight_smile:

I’ve been trying to run fastpages locally on my Windows 10 laptop for over 2 hours. No luck so far, I’m not even able to run the make server command because I don’t seem to understand Docker/WSL2.

Before I spend even more time digging deeper, is it even possible what I imagine: editing notebooks or CSS files in Windows and seeing the results locally on my machine; without pushing the changes to github and cloning them into WSL every time?

Thank you guys.

Hi @johannesstutz can you share more so that someone can help you. And yes, you can see the results locally on your machine. That’s what make server is doing, however you have to have Docker installed correctly etc before this can happen.

1 Like

Hi Hamel, thank you for your reply! I did not give any details because I thought it wouldn’t be a good use of your time to explain Docker to me :slight_smile:

However, maybe someone can help me. I don’t know where to run the make server command. I have Docker running and WSL2 installed. Which command line tool do I have to use?

Do I have to install Ubuntu or another distribution or is the built-in Linux fine? (I tried installing Ubuntu 20.04 LTS from the Windows Store but that did not work)

Please carefully read this https://github.com/fastai/fastpages/blob/master/_fastpages_docs/DEVELOPMENT.md its linked to from the README

I’ve read the development guide carefully. My problem however is very basic: after I install Docker - where do I find the CLI where I enter make server? (So it’s not about which make command to use when or in which directory, but where I have to physically enter these lines)
Sorry for these extremely basic questions.

Oh sorry I see I totally misunderstood! Thanks for clarifying that! I don’t have Windows but is there a WSL terminal window you can use? Does this help? https://docs.microsoft.com/en-us/windows/wsl/install-win10

If not let me know! Don’t be shy in letting us know where you are stuck will try to find a friend who uses windows to help out

Thanks, Hamel :slight_smile:

I think I have successfully installed WSL 2:

I then installed Ubuntu 20.04 LTS for Windows.

When I try to run the makefile on Ubuntu it raises this error:

So I think this means it can’t access Docker (which I installed on Windows). I also checked if the “WSL integration in Docker Desktop settings” is activated, and it is (I think):

So that’s where I’m stuck. I’m glad for any help, but it’s not critical in any way. I just would love to be able to preview blog posts locally :slight_smile:

Someone who knows windows will have to help, I have no idea.

@johannesstutz You have to install WSL2 and Ubuntu before you install Docker for the Docker WSL2 backend to install properly. See info/instructions via the link below.

2 Likes

Awesome, this helped! :slight_smile:

Everything is up and running now.

Two minor issues:

  1. I have to use htttp:// to connect to the Jekyll server, not https://, this might be an error in the development guide?
  2. Automatic rebuilding on file change is not working, I have to restart the server to see any changes. I think this is because I have stored the files on the Windows filesystem. No big deal.

Thank you for your help @hamelsmu and @neuradai :slight_smile:

Maybe its your browser cache. Have you tried a hard refresh of your browser?

It wasn’t the browser cache, but I found a way to fix it :slight_smile: It’s related to this issue of WSL. And somebody found this solution for Jekyll.

So I changed the fastpages Dockerfile, adding the --force-polling argument to Jekyll:

jekyll:
    working_dir: /data
    image: fastai/fastpages-jekyll
    restart: unless-stopped
    ports:
      - "4000:4000"
    volumes:
      - .:/data/
    command: >
      bash -c "chmod -R u+rw . && jekyll serve --force_polling --host 0.0.0.0 --trace --strict_front_matter"

Now I can edit files on C:\ in Sublime for Windows, reload the page and all changes are instantly visible. Perfect!

Edit: unfortunately, it only works for static files like CSS and HTML, not for Jupyter notebooks. Those still require a restart of the server.

1 Like