Jupyter Notebook crashes, then get connection refused error and cannot relaunch on mac

88 views
Skip to first unread message

S Benton

unread,
Apr 23, 2024, 3:16:21 PMApr 23
to sage-support
Hi - at my wit's end here - my daughter is trying to use Sage Math Jupyter Notebook for her college coursework. She has had problems where if Notebook crashes, she is unable to relaunch it - she gets a "connection refused" error and it mentions Local Host 8888. Last time, we reinstalled everything and she was able to get up and running again. However, this keeps happening.

I am wondering if - when Notebook crashes - if there are still processes running out there that are preventing her from relaunching a new instance of Notebook. She is on a mac, and I'm trying to find the commands or directories where these processes or files might stored so that I can remove them.  

I am not able to use any of the "Jupyter" commands from the mac command line to see what is running. Does anyone have any help they can offer on why this might be happening and how i can get her up and running again?

Many thanks

Dima Pasechnik

unread,
Apr 23, 2024, 4:05:17 PMApr 23
to sage-s...@googlegroups.com
Hi,

please tell us more about the Sage version, and how you installed it, and how you launch the notebook.

Do you use the Sagemath macOS app?


Dima

S Benton

unread,
Apr 23, 2024, 5:29:36 PMApr 23
to sage-support
Hi,

We are not using the app.  She downloaded SageMath-10.3_arm64.dmg from github., double clicked the executable and followed the installation instructions. To launch, she clicks the SageMath-10-3 icon along the bottom of her mac. This gives her the option to open Jupyter Notebook, which she does, using the SageMath kernel.

She has a 3 year old mac and I'm wondering if it just doesn't have the processing power it needs to do these more intensive mathematical computations. (plus she probably has other stuff up on her computer) So when Jupyter Lab konks out, she is unable to restart it. Even if she reboots her computer, when she tries to relaunch from the SageMath icon, she gets the Local host Error connection refused. She looks in Activity Monitor and says she has killed all of the python processes, but still cannot launch SageMath. 

The last time this happened we removed and then reinstalled SageMath. But that's a tough way to keep things moving. I'm wondering if when Jupyter Lab dies, if there are files that live on and make it so that she cannot relaunch. We have not been able to find, or just lack the skills to find, where any of these files might be located. I tried to run "jupyter" commands from the terminal, but they come back as unknown and searching through "finder" on the mac is not getting us anywhere.

Short of buying a new computer or continuing to reinstall SageMath, I'm wondering if there is a simpler of way of getting things up and running again for her.

Thank you so much for responding. It is deeply appreciated.



Dima Pasechnik

unread,
Apr 23, 2024, 5:57:38 PMApr 23
to sage-s...@googlegroups.com, Marc Culler
On Tue, Apr 23, 2024 at 10:29 PM S Benton <brent...@gmail.com> wrote:

> We are not using the app. She downloaded SageMath-10.3_arm64.dmg from github., double clicked the executable and followed the installation instructions. To launch, she clicks the SageMath-10-3 icon along the bottom of her mac. This gives her the option to open Jupyter Notebook, which she does, using the SageMath kernel.

OK. What macOS version do you run?
Do you have all the updates installed ? (you should)

>
> She has a 3 year old mac and I'm wondering if it just doesn't have the processing power it needs to do these more intensive mathematical computations. (plus she probably has other stuff up on her computer) So when Jupyter Lab konks out, she is unable to restart it. Even if she reboots her computer, when she tries to relaunch from the SageMath icon, she gets the Local host Error connection refused. She looks in Activity Monitor and says she has killed all of the python processes, but still cannot launch SageMath.

it's most probably a stale "lock" file, just a file created by a
process to indicate that it's running; such a file is cleaned on a
normal exit,
but not in case of a crash.

I must say I don't know much about this app, I'll cc to one of the authors.

Marc, could you have a look?

The app has a dedicated issue tracker:
https://github.com/3-manifolds/Sage_macOS/issues
it might be better to report there.

>
> The last time this happened we removed and then reinstalled SageMath. But that's a tough way to keep things moving. I'm wondering if when Jupyter Lab dies, if there are files that live on and make it so that she cannot relaunch. We have not been able to find, or just lack the skills to find, where any of these files might be located. I tried to run "jupyter" commands from the terminal, but they come back as unknown and searching through "finder" on the mac is not getting us anywhere.
>
> Short of buying a new computer or continuing to reinstall SageMath, I'm wondering if there is a simpler of way of getting things up and running again for her.
>
Certainly a 3 y.o. machine is more than enough to run Sage, it's some
kind of software glitch, I suppose.
I'm running Sage (and writing this email from a 7 y.o. machine just fine).

A quick way to run Sage is to use https://cocalc.com
(you can upload Jupyter notebooks there to run; you can even use it for free,
but to make it run better you'd need to pay something like $7 per month)

There are several other ways to run Sage locally on your mac,
but let's try things in turn first.

Hope this helps,
Dima

> Thank you so much for responding. It is deeply appreciated.
>
>
>
> On Tuesday, April 23, 2024 at 4:05:17 PM UTC-4 Dima Pasechnik wrote:
>>
>> Hi,
>>
>> please tell us more about the Sage version, and how you installed it, and how you launch the notebook.
>>
>> Do you use the Sagemath macOS app?
>>
>>
>> Dima
>>
>>
>> On 23 April 2024 20:05:12 BST, S Benton <brent...@gmail.com> wrote:
>>>
>>> Hi - at my wit's end here - my daughter is trying to use Sage Math Jupyter Notebook for her college coursework. She has had problems where if Notebook crashes, she is unable to relaunch it - she gets a "connection refused" error and it mentions Local Host 8888. Last time, we reinstalled everything and she was able to get up and running again. However, this keeps happening.
>>>
>>> I am wondering if - when Notebook crashes - if there are still processes running out there that are preventing her from relaunching a new instance of Notebook. She is on a mac, and I'm trying to find the commands or directories where these processes or files might stored so that I can remove them.
>>>
>>> I am not able to use any of the "Jupyter" commands from the mac command line to see what is running. Does anyone have any help they can offer on why this might be happening and how i can get her up and running again?
>>>
>>> Many thanks
>
> --
> You received this message because you are subscribed to the Google Groups "sage-support" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to sage-support...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/sage-support/12aa12b6-1574-46d8-99b8-f6d72252166an%40googlegroups.com.

Dima Pasechnik

unread,
Apr 23, 2024, 6:08:43 PMApr 23
to sage-s...@googlegroups.com, Marc Culler
PS. From what I see on https://github.com/3-manifolds/Sage_macOS/issues/28
I gather you might try to remove (or better, rename, to be on the safe
side) the folders

~/Library/Application Support/SageMath/*/Jupyter

in other to be able to start Jupyter again.

Marc Culler

unread,
Apr 23, 2024, 6:56:34 PMApr 23
to sage-support
Please ask her to try removing the two directories ~/Library/Jupyter and ~/.sage:
rm -rf ~/Library/Jupyter
rm -rf ~/.sage

If that does not fix it, please open an issue at our github site:
We will work through it with you and figure out what is going wrong.

- Marc

Marc Culler

unread,
Apr 23, 2024, 6:58:30 PMApr 23
to sage-support
The 10.3 version of the app uses the standard location for Jupyter runtime files: ~/Library/Jupyter

- Marc

S Benton

unread,
Apr 24, 2024, 12:31:38 AMApr 24
to sage-support
An enormous and sincere thank you to all of you! I will make sure her mac os is updated and have her remove the above directories/files.  Hopefully that will do the trick, but if not I will open an issue at github. And yes - she tried Cocalc and it got her able to submit her assignment tonight, at least!

Thank you again!!!

Marc Culler

unread,
Apr 24, 2024, 9:26:05 AMApr 24
to sage-support
Please also have her remove the directory:
~/Library/Application\ Support/SageMath-10-3/Jupyter

I misstated where the Jupyter runtime directory is located for the current 10.3 app, and this is also different from the directory that Dima mentioned, which was used by 10.2 and earlier.

When the SageMath-10.3  jupyter kernel starts up it creates files in its runtime directory describing how to connect to the kernel.  When the SageMath app shuts down it sends a TERM signal to the kernel process it started.  When that kernel process receives the signal it removes the files it created.  Sometimes it can happen that a kernel is killed in a way, which prevents it from removing its runtime files.  This can cause a later invocation of jupyter to try connecting to a non-existent kernel or to use an invalid token when connecting to an existing kernel.

- Marc

S Benton

unread,
Apr 24, 2024, 1:57:44 PMApr 24
to sage-support
I will have her do this and let you know if it works. If it doesn't, I will raise a ticket as indicated earlier. THANK YOU!!

S Benton

unread,
Apr 30, 2024, 10:03:16 PMApr 30
to sage-support
Just to follow up - removing the above files and restarting Jupyter Notebook WORKED!!! THANK YOU!!!!!
Reply all
Reply to author
Forward
0 new messages