Video works correctly in local deployment but won't load when deployed on EC2

I think the solution to my issue is just to host the mp4 files on an S3 instance and use the urls for st.video but I’m just hoping for an explanation or some guidance for understanding the issue myself.

The situation is that I am displaying a video using st.video on a local mp4 perfectly fine when deployed locally. When copying my app to an AWS EC2 instance and deploying via docker, everything works great except that the video fails to load. Inspecting the browser shows the mp4 exists in the media folder under application (for both cases), but if you wait long enough you get a
“Failed to load resource: net::ERR_CONNECTION_RESET” error for the EC2 case. An image that I’m using for st.logo works fine in both cases and it located in the same folder as the mp4 if that helps at all.

Again, I think hosting the video somewhere else and linking to it will solve my issue but I’m mostly just curious as to why it isn’t working or how could I figure out why it’s not working because it’s been bugging me a little.

Any insight is greatly appreciated. Btw, I’ve been loving learning streamlit over the past few months. The documentation is super helpful and very easy to navigate and learn from. Great work guys

The “Failed to load resource: net::ERR_CONNECTION_RESET” error typically indicates that there is an issue with how the video is being served, whether it’s related to permissions, file paths, or network access. Video might work locally because the path is likely being resolved to a local directory that the Streamlit app can access directly. However, when deployed on EC2 with Docker, the application might not be able to resolve the path properly, or the file might not exist in the Docker container.

The ERR_CONNECTION_RESET error could also be related to network issues. If you’re accessing your EC2 instance via an IP or a domain, ensure that the EC2 instance’s security group allows inbound traffic on the port used by your Streamlit app.

As you mentioned, hosting the video on AWS S3 and using the S3 URL in st.video() is a good workaround and often the easiest way to handle large static files like videos. S3 is designed to serve static content.

1 Like