Strange and Subtle Refresh Streamlit Bugs

Has anyone else noticed that streamlit appears to have a few strange and subtle bugs? I’ve noticed a couple oddities:

  1. Sometimes streamlit reloads unexpectedly and all multi-select widgets are reset to their default values. However, based on what code runs, the values returned by the widgets still seem to be the old values for the first such run of the app. Then the next time the user modifies a widget’s value the default values of the multi-select widgets end up being used instead.
  2. Sometimes an entire streamlit app crashes unexpectedly and the page needs to be refreshed. This can happen either when entering input or while waiting for code to rerun. It’s probably not related, but I’ve become wary of scrolling up and down the page and interacting with already-plotted alt-air charts while waiting for code to run because it sometimes appears to induce these crashes.

I would try to create a minimal working example of these, but I’m not really sure how to reproduce these bugs – they only happen some of the time when I run my app.

Has anyone else experienced similar issues? They seem to occur infrequently enough that they are more of an annoyance than a problem for my purposes, but they are still frustrating to have to deal with.

It may be unrelated, but one of the issues mentioned in this question sounds a bit similar. Avoid rerunning for intermediate values for number_input, slider etc

1 Like

Hey @Yasha,

Answering to your questions:

  1. Streamlit does a rerun everytime that is some change either in the script or a change made by the user within the App. There are some cases that you could need to store the state between reruns you could solve that using st.cache or “Session State” like is shown in this discussion

  2. We are going to be needing an example to try it out

Please let us know if this helps you

Hi @arraydude

  1. Yep, I know. that’s not the kind of rerun that I’m referring to. I’m talking about reruns that occasionally happen outside of those two cases.
  2. Fair enough. Unfortunately, as I said, I am unable to reliably reproduce either of these two bugs. They appear to happen at random as far as I can tell.

Unfortunately your answer was no help. However, I know I didn’t give you much to work with, so I didn’t expect a solution. I’m mostly curious to know if others have encountered similar issues.

I was able to reproduce the case when nothing update (including the page content: it’s totally white).
Consider two files,

import streamlit as st
import pandas as pd

# My first app
Hello *world!*

df = pd.DataFrame({
  'x': list(range(100)),
  'y': list(map(lambda x: x*x, range(100)))


and (which started by stremlit run)

import code

then first time you change anything the show does. After page refresh, there are none.

Workaround: wrap other files code to function and call it

Hello @api_access

You’re encountering this behavior because streamlit won’t re-import everything when you re-run your, thus your's body won’t be re-executed. By wrapping everything in a function like you said, you can explicitly call it in to execute everything.

@Yasha, is this what you are talking about? Notice here in below gif, I am selecting No for both the radio buttons and then suddenly the page reloads and the values are reset to default Yes again. I don’t know how to tackle this! Maybe I am doing something wrong or I am missing something.

Also this happens only like 6 out of 10 times or so, not always!

An additional gif for more clearer demonstration… (1)

Hi Benison_Sam (welcome!) Thanks for reporting this issue. A couple quick questions:

  • What version of Streamlit you’re running?
  • Do you have the source of the app somewhere, or a reproducible test case we can run?
1 Like


I have encountered the same issue several times, particularly if there are a lot of user inputs.
My version is 0.71.0. Unfortunately, I cannot share the source code and it is not possible to reliable reproduce the error since it is unpredictable. However, my error is basically the same error Benison_Sam presented via gif.

Example: My app has “Main Page” and a few other “pages” which are not related to each other (each page contains code and functions which are ran only on that page). After I complete some task on “Page 1” and go to “Page 2” to complete some other tasks, sometimes the whole app refreshes after I click a button or upload a file and it returns me to “Main Page”. When I go back to “Page 2” I can see that the files are uploaded, but I have no idea why it returned me to “Main Page”.

P.S. Different pages were handled via st.selectbox()

Thank you in advance!

I have run into this issue as well.

Something similar to what @Benison_Sam has illustrated happens. Sometimes my application, when running cross-validation computations, will suddenly stop and reset everything. I am using version 0.72.0.

I cannot share the source code and, like the others have stated, this is something that only happens sometimes thus it is hard to reproduce the error.

Hello everyone,

Those refreshes can be a real Streamlit bug, or some code flow issue in your apps.
Unfortunately with no code sample, It’s going to be hard to identify what’s the matter.

Hello everyone,

I have added a snippet of my original code to this repo with instructions under the file on how to try to reproduce this strange behaviour. Then again, it might be hard to do reproduce it as it presents a somewhat random nature, but I have noticed, on my specific application, that it is more common when the Yearly seasonality parameter is set to True.

After pressing the Validate button the app will appear to be running smoothly for a few iterations of the process and then, all of a sudden, the text on the top right-corner will change from RUNNING… to CONNECTING… (see images below) and the app will completely reset.



Let me know if you have any ideas on this issue.
Thanks in advance!