3

I'm trying to run Jupyter notebooks from WSL (Windows Subsystem For Linux). The default port it uses is localhost:8888

However if I try to reach that in my browser, nothing happens.

If I start Jupyter with jupyter notebook --port 8080, I can connect with localhost:8080 with no problems.

So I think this is a firewall problem. I am running Windows Defender but am pretty clueless with it. I tried setting an Incoming Rule to allow port 8888, following the instructions here but it didn't help. Then I tried adding an Outgoing Rule as well, but that didn't help either.

I'm probably doing something very simple wrong.

Any ideas?

1 Answers1

0

First, let have some prior knowledge about how to get WSL distribution binary path. See any of these Q&A from SuperUser:

After installing jupyter notebook in WSL, resolve the full path of python binary. Get the distribution installed path from previous answer and append these ones:

  • Python2: \rootfs\usr\bin\python2.7
  • Python3: \rootfs\usr\bin\python3.5

The full path will be like this:

C:\Users\%USERNAME%\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu18.04onWindows_79rhkp1fndgsc\LocalState\rootfs\usr\bin\python3.5 

Too long, isn't it? Now allow it in Windows Firewall. It is possible with Windows Firewall Management Console (wf.msc). Here netsh command is used. Run this command as administrator:

netsh advfirewall firewall add rule Name=Python Program="put-the-path-here" LocalPort=8888 Action=allow Dir=Out 

Or with PowerShell:

New-NetFirewallRule -DisplayName "Python" -Name "Python" -Direction Outbound -Program "put-the-path-here" LocalPort 8888 -Action Allow 

This will allow port 8888 for that python binary. If the Windows side browser is also firewall-ed then allow it to accept the connection. For further details, see netsh and New-NetFirewallRule command syntax.

Biswapriyo
  • 11,584