Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WSL 2 localhost domain alias does not correctly redirect or work #6426

Closed
AssisrMatheus opened this issue Jan 12, 2021 · 1 comment
Closed

Comments

@AssisrMatheus
Copy link

When adding a domain alias to 127.0.0.1, for example app.local, and running a server on WSL 2, the alias is not mapped to WSL network as it happens with localhost.

Look at both commands being ran:
image

hosts file setup:
image

I have to manage different cookies so one of my apps can't have localhost or it will conflict with the other app's cookies. This is fixed by running one of the apps using app.local:3000 since the cookies are then set separately to that domain. Also, Auth0 lock requires us to do that for local development: https://auth0.com/docs/authorization/user-consent-and-third-party-applications#skip-consent-for-first-party-applications.

But I can't get it to work.

Environment

Windows build number: Microsoft Windows [Version 10.0.19042.685]
Your Distribution version: 20.04
Whether the issue is on WSL 2 and/or WSL 1: Linux version 4.19.128-microsoft-standard (oe-user@oe-host) (gcc version 8.2.0 (GCC)) #1 SMP Tue Jun 23 12:58:10 UTC 2020

Steps to reproduce

  • Edit windows hosts file at c:\windows\system32\drivers\etc\hosts and add 127.0.0.1 app.local to the last line
  • Edit WSL2 hosts file at /etc/hosts and add 127.0.0.1 app.local to the last line
  • (Optional) Restart the computer so WSL hosts file will be automatically synced with windows'
  • Reopen a terminal window
  • Run a network server in a port (I'm using 3000 since I'm working with a react app).
  • Open https://localhost:3000/ in your browser. It will work
  • Open https://app.local:3000/ in your browser. It won't work

Expected behavior

You should be able to see your app/server

Actual behavior

The browser shows the ERR_CONNECTION_REFUSED error.

@AssisrMatheus
Copy link
Author

I got it to work. I had to also add ::1 app.local in the hosts file and reboot the machine. Then it was working as expected

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant