wsl2

windows 에서 wsl2 localhost 접근하기

wefree 2021. 12. 27. 21:57

문제

wsl2 ubuntu 터미널에서 아래처럼 서버를 port 8000 으로 실행해 두었다.

windbird@AL01929730:~/tmp$ cat index.html
Hello !!!
windbird@AL01929730:~/tmp$ python3 -m http.server
Serving HTTP on 0.0.0.0 port 8000 (http://0.0.0.0:8000/) ...

windows 에서 서버에 접근할려면?

 

해결

windows browser 에서 아래처럼 접근하면 된다. 

http://localhost:8000/

접근이 잘 안된다면 서버가 아래처럼 localhost 가 아닌 0.0.0.0  로 실행되었는지 확인해 본다.

windbird@AL01929730:~/tmp$ python3 -m http.server
Serving HTTP on 0.0.0.0 port 8000 (http://0.0.0.0:8000/) ...

 

설명

반대로 windows 에서 실행된 서버를 wsl2 ubuntu 터미널에서 접근하려면, wsl2 에서 windows localhost 접근하기 를 참고하도록 한다.