This sounds like the issue described here, which is basically that the /upload endpoint used by Streamlit has its request routed to a different node than the one that the frontend is connected to (I’ll paste the longer explanation from @vdonato below too in case you’re curious).
The TDLR is that the best way to resolve this error is to enable session affinity/sticky sessions within Azure. Here’s a doc that describes where you can find this setting.
Coincidentally, we’re currently working on a project that will eventually enable users to configure pieces of the file uploader widget so that it can operate more smoothly in multi-instance deployments. We’ve recently worked on several projects with a similar theme of making the Streamlit internals more configurable, but the piece we’re missing before we’ll be able to expose all of these things publicly is a more advanced config system. See this comment on a similar issue for more context: #5849 (comment).
That being said, even once everything is available for public use, I’d probably still recommend relying on session affinity to get st.file_uploader to work as expected in most multi-instance deployments.
The difficulty with getting a widget like the file uploader to work correctly when there are several streamlit server instances (assuming no session affinity) is that the file upload, which happens via HTTP as sending large files via websocket comes with its own set of difficulties, may land on a different server than the one the browser has a websocket connection to. As a result of this, a solution would require either
Streamlit servers to be able to talk to each other to pass files around
This would require some nontrivial configuration outside of streamlit itself to enable service discovery. It also feels somewhat hacky
A way to upload files to a shared location (like AWS S3 or some other intermediary service) rather than directly to an individual streamlit server
This is what the in-progress changes to the file uploader widget will enable. It feels like the more “correct” solution to me
The difficulty with both solutions is that they’re far from “automatic” – developers will have to do a nontrivial amount of work outside of Streamlit to get everything set up. While some users will certainly have use cases where it’s worth the effort to do this (including us at Snowflake, which is why we’re building this configurability into the file uploader to begin with), I’d imagine that it wouldn’t be worth the effort compared to just turning on sticky sessions in most situations.
Thanks for stopping by! We use cookies to help us understand how you interact with our website.
By clicking “Accept all”, you consent to our use of cookies. For more information, please see our privacy policy.
Cookie settings
Strictly necessary cookies
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
Performance cookies
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
Functional cookies
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
Targeting cookies
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.