TJ

TEAMMATES on WSL2

February 12, 2021 • ☕️ 1 min read

Networking issues with WSL2

WSL2 is becoming a more common way to use Linux on Windows. However, it is still in its early stages, so there are some teething networking issues.

For example, you won’t be able to start TEAMMATES on WSL2 by following the contributing instructions. Instead, you’ll receive a 404 error without any error logs.

What’s the problem?

In the default settings of WSL2, /etc/hosts aliases localhost to 127.0.0.1. In Windows (build 19041) localhost resolves to ::1.

So the server in WSL2 was listening on 127.0.0.1 and the browser was trying to reach ::1. No wonder it didn’t work!

What’s the solution?

  1. Open up /etc/hosts, and do 2 things:

a. Remove the line containing 127.0.0.1 from /etc/hosts

b. Add localhost to the line containing ::1

Your hosts file should look like this at the end:

/etc/hosts config

  1. Prevent the file from being generated with wrong configuration by locking it.

The following command makes the hosts file immutable:

chattr +i hosts
  1. We’re done! Restart your shell and follow the contributing instructions to get TEAMMATES working.

Have fun contributing!