Can't stop streamlit app using Ctrl+C if the app has been closed in the browser

Summary

This is a continuation of a thread from last year: Streamlit server 1.5.1 from command line, hard to stop with CTRL C

This issue does not seem to be resolved and I am perplexed if this is intended behavior or an issue that has not been fixed. Basically if you have a streamlit app running and close the browser, trying to stop the app with ctrl+c does not work.

Steps to reproduce

  • close browser app when streamlit is running
  • ctrl+c in the terminal
  • app does not stop running
  • open the app from the URL link so it opens in the browser again
  • ctrl+c in the terminal
  • app stops running (yay!)

Expected behavior:

  • Launch streamlit from the terminal
  • Close browser
  • ctrl+c in the terminal
  • app stops running (yay!)

Actual behavior:

  • Launch streamlit from the terminal
  • Close browser
  • ctrl+c in the terminal
  • app does not stop running (boo!)

Debug info

  • Streamlit version: 1.19.0
  • Python version: 3.9.12
  • Using venv
  • OS version: Microsoft Windows 11 Home 10.0.22621 Build 22621
  • Browser version: Chrome Version 110.0.5481.178 (Official Build) (64-bit)

Requirements file

streamlit
omegaconf
Pillow

3 Likes

I can confirm this behavior. When I close the browser tab, the terminal no longer responds to Ctrl+C, I have to kill the process or close the terminal session.
However, if I remember correctly, this behavior only occurs under Windows.
These are my boundary conditions: Windows 10, Firefox, cmder terminal, Streamlit 1.19.0
I have not tried other browsers or other terminals.

1 Like

I have seen this in Windows 10 with both streamlit and jupyterlab (both use tornado).

1 Like

I can also confirm. windows 11. finally I had multiple situations the app closing immediately starts if you CTR+click again on the localhost link to start the app again after closing the browser. So at least there is a workaround vs waiting atm.

1 Like

Same behaviour here on Windows 10 using Microsoft Edge and Windows command line in PyCharm. Indeed, the workaround is to reopen the link to the Streamlit app and the terminal will be able to kill the process successfully.

1 Like

Normally I just crazy press Ctrl+C till it stops…
Takes around 5 - 20 times :face_exhaling:

3 Likes

I can also confirm this under Windows 10. I always thought this behaviour was intended (even though annoying). In short: When no tab is connected to the streamlit server, you cannot terminate the streamlit server by pressing CTRL+C in the terminal. You have to open a new tab first. Only then CTRL+C will actually go through.

2 Likes

Same issue here

1 Like

I couldn’t find a current or closed issue talking about this directly, so I went ahead and created an issue in GitHub: Cannot Ctrl+C to end streamlit process from CLI without an open tab (in Windows) · Issue #6855 · streamlit/streamlit · GitHub

2 Likes

it worked for me

1 Like

This continually happens to me on Mac and Chrome. Ctrl+C works for awhile. and then stops receiving input and hangs. This is something like 6-10 runs when it happens.

1 Like

new to steamlit and quickly found this bug while working in vscode.

here’s my workaround:
Run menu → Start Debugging
If a warning pops up, click yes
Stop the debugging session

simply clicking F5 will not trigger a new debug session.

1 Like

It also works to open a new tab to the app. If you open a new tab to the right localhost port, the Ctrl+C command can complete.

5 Likes