Gatsby: run Gatsby through WSL2

Created on 26 Jun 2019  路  13Comments  路  Source: gatsbyjs/gatsby

Had trouble running gatsby develop through WSL2 (Windows subsystem for Linux v2)

context

WSL2 is available, it is still in the early stages.
https://devblogs.microsoft.com/commandline/wsl-2-is-now-available-in-windows-insiders/
https://docs.microsoft.com/en-us/windows/wsl/wsl2-ux-changes

Steps to reproduce

Run gatsby develop from WSL2.

Actual result

Browser reports connection refused

(Temporary) solution

  1. Get the correct ip address by running
ip addr | grep eth0

and copying the ip after inet

  1. Start the Gatsby development server with
gatsby develop -H 0.0.0.0
  1. Open browser on the ip from step 1 at the port reported by gatsby develop (8000)

Thanks to @lannonbr on the Gatsby discord for the solution!

The WSL2 team will probably change how connecting to localhost works in the future, so this solution should be temporary.

stale? documentation

Most helpful comment

@wardpeet @lannonbr
I just installed the 2004 update for windows 10 which officially brings WSL2 with it. The issue still seems to persist under WSL2 and I'm happy to help understand and debug it. Exposing to the network using -H 0.0.0.0 also still works.

All 13 comments

So for now my suggestion was to expose it out to the network with -H 0.0.0.0. It works, but I am not sure if this is the perfect solution. This may be good to add to the docs under the Gatsby on Windows page.

Hiya!

This issue has gone quiet. Spooky quiet. 馃懟

We get a lot of issues, so we currently close issues after 30 days of inactivity. It鈥檚 been at least 20 days since the last update here.

If we missed this issue or if you want to keep it open, please reply here. You can also add the label "not stale" to keep this issue open!

As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contributefor more information about opening PRs, triaging issues, and contributing!

Thanks for being a part of the Gatsby community! 馃挭馃挏

I'm marking this stale. If people aren't running into this too often, this isn't a pressing issue. We can deal with it again when it pops up a bit more or when wsl2 becomes mainstream.

I think this has been updated in a newer insiders release of WSL 2 as discussed here: https://devblogs.microsoft.com/commandline/whats-new-for-wsl-in-insiders-preview-build-18945/

@NickyMeuleman, can you possibly download this new version and verify that this issue has been resolved?

Ooh, that sounds very exciting!
will report back :) thanks for the heads up.

Edit: been playing around with this, and it doesn't seem to work across the board.
While things like create-react-app works, Gatsby does not.

When connecting I get the connection refused error again.

(pinging @lannonbr, since I edited this reply)

I'm unsure this is something we can address as of now. WSL 2 is still in beta and might be a windows issue rather than a gatsby issue.

Alright yeah that's fine. Thanks anyway for the testing @NickyMeuleman

I will close this now and keep it on file so if this issue persists when WSL2 is stable this fall, then we can look into it.

@wardpeet @lannonbr
I just installed the 2004 update for windows 10 which officially brings WSL2 with it. The issue still seems to persist under WSL2 and I'm happy to help understand and debug it. Exposing to the network using -H 0.0.0.0 also still works.

Alright, reopening the issue

Hiya!

This issue has gone quiet. Spooky quiet. 馃懟

We get a lot of issues, so we currently close issues after 30 days of inactivity. It鈥檚 been at least 20 days since the last update here.
If we missed this issue or if you want to keep it open, please reply here. You can also add the label "not stale" to keep this issue open!
As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contribute for more information about opening PRs, triaging issues, and contributing!

Thanks for being a part of the Gatsby community! 馃挭馃挏

Hey again!

It鈥檚 been 30 days since anything happened on this issue, so our friendly neighborhood robot (that鈥檚 me!) is going to close it.
Please keep in mind that I鈥檓 only a robot, so if I鈥檝e closed this issue in error, I鈥檓 HUMAN_EMOTION_SORRY. Please feel free to reopen this issue or create a new one if you need anything else.
As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contribute for more information about opening PRs, triaging issues, and contributing!

Thanks again for being part of the Gatsby community! 馃挭馃挏

I'm having trouble running gatsby develop -H 0.0.0.0 --https on WSL2

This is purely a guess but from what I've read of the documentation on the topic, devcert is adding the certificate on the wsl side of things which means that when opening the site through a browser (on the windows side) the server is just refusing to connect.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

andykais picture andykais  路  3Comments

theduke picture theduke  路  3Comments

ghost picture ghost  路  3Comments

kalinchernev picture kalinchernev  路  3Comments

KyleAMathews picture KyleAMathews  路  3Comments