Ask Your Question
1

Why doesn't 'sage -n jupyterlab' open correctly ?(localhost refused to connect)

asked 2023-06-16 15:41:58 +0100

licheng gravatar image

updated 2023-06-26 09:46:14 +0100

FrédéricC gravatar image

I installed Sage and JupyterLab in WSL (Arch Linux).

sudo pacman -S sagemath
sudo pacman -S jupyterlab

Its command line seems to work fine. image description

However, after the first run of sage -n jupyterlab that successfully opens JupyterLab, I cannot open JupyterLab again after restarting my computer.

image description

Even if I copied those URL-like links it mentioned.

image description

How should I adjust it correctly?

edit retag flag offensive close merge delete

Comments

This might point to a "too cautions" firewall configuratin : your machine refuses connections from itself (localhost, a. k. a. 127.0.0.1) on the port 8927. traceroute and nc are your friends...

WSL configuratuion may also be in cause : it might or might not accept connections (and ISTR that it may depend on the WSL version...).

Emmanuel Charpentier gravatar imageEmmanuel Charpentier ( 2023-06-16 17:21:29 +0100 )edit

BTW : textual cut'n'paste is way prefferable to screen dumps...

Emmanuel Charpentier gravatar imageEmmanuel Charpentier ( 2023-06-16 17:25:53 +0100 )edit

@Emmanuel Charpentier Thanks. I'm not sure if it's because of the directory, but I encounter an error when opening WSL from the directory in Windows. However, when I switch back to the WSL directory, it opens correctly. The directory may have a significant impact.

licheng gravatar imagelicheng ( 2023-06-18 03:12:36 +0100 )edit

2 Answers

Sort by » oldest newest most voted
2

answered 2023-06-18 12:20:18 +0100

slelievre gravatar image

updated 2023-06-18 12:27:32 +0100

Instead of sage -n jupyterlab, try running jupyter lab.

The error might have to do with the "redirect file". See

edit flag offensive delete link more
1

answered 2024-10-21 16:57:48 +0100

cks2024 gravatar image

My computer environment: Windows 10 20H2 (19042.630), ubuntu 22.04.5 LTS in WSL 2, SageMath version 10.4 in ubuntu.

After my first successful run of sage -n, I also encountered this issue. Strangely, about 20 minutes later, I was able to open Jupyter Notebook using the same steps (typing sage -n and copying the link into the browser on my Windows main system), despite not changing anything on either my Ubuntu subsystem or Windows main system.

I’ve also noticed that once I’m in the notebook, if I close the browser by directly clicking the red “X” in the corner, I often can't access the notebook again. However, if I go to "File -> Log Out" on the Jupyter Notebook home page, and the page confirms with “Successfully logged out”, I can always re-enter the notebook using the same steps, even after restarting my computer.

My guess is that each time we generate a link via sage -n and open it in the browser, it occupies a specific web port. If we leave it idle for too long, the link becomes invalid. When the browser is closed directly, the previous link remains active, and since the port can only be used by one link, we can’t re-enter with a newly generated link from sage -n. Instead, we have to wait for the previous link to expire. By clicking Log Out, the link is properly terminated, allowing the system to accept a new link immediately.

Currently, I’m not sure if there are other ways to manually terminate the previous link either from Ubuntu subsystem or from Windows main system. For now, using "File -> Log Out" is a reliable way to avoid this issue. If the problem does occur, waiting for the link to expire might be a solution.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2023-06-16 15:41:58 +0100

Seen: 409 times

Last updated: Jun 18 '23