Blog
3 min read

How to Deploy a Streamlit App: Community Cloud or Your Own Server

Two good ways to put a Streamlit app online: Streamlit Community Cloud for free public apps straight from GitHub, or your own server with systemd and Nginx for private apps, more resources and no sleeping. Step-by-step for both, including secrets, requirements.txt and the WebSocket setting that trips people up.

You've built a Streamlit app — a dashboard, a data tool, an AI demo — and streamlit run app.py works on your laptop. Now you want a link you can share.

There are two main routes:

Streamlit Community Cloud Your own server
Cost Free Server cost
Setup Minutes, from GitHub Half an hour
Private data / private repo Limited Full control
Resources Modest, shared Whatever you pay for
Sleeps when idle Yes No

Before either: get the repo ready

  1. A requirements.txt listing every package your app imports:
streamlit
pandas
plotly

Pin versions once it works (streamlit==1.x.y) so deploys are repeatable. (requirements.txt)

  1. No secrets in the code. Read them with st.secrets (or environment variables) instead:
import streamlit as st
api_key = st.secrets["OPENAI_API_KEY"]

Locally they go in .streamlit/secrets.toml — add that file to .gitignore. (.gitignore Explained)

  1. Push to GitHub.

Option 1: Streamlit Community Cloud

  1. Sign in at share.streamlit.io with GitHub.
  2. Click Create app, choose your repo, branch and main file (app.py).
  3. Under Advanced settings, paste your secrets in TOML format and pick a Python version.
  4. Deploy. You get a *.streamlit.app URL.

Every push to the branch redeploys. The trade-offs: apps go to sleep after a period without visitors (the next visitor waits for a wake-up), resources are limited, and it's designed for apps that are fine being public.

Option 2: your own server

On a Linux server with Python installed:

git clone https://github.com/you/dashboard.git
cd dashboard
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
streamlit run app.py --server.port 8501 --server.address 127.0.0.1

(Python Virtual Environments)

Keep it running with systemd so it survives crashes and reboots:

# /etc/systemd/system/dashboard.service
[Unit]
Description=Streamlit dashboard
After=network.target

[Service]
User=app
WorkingDirectory=/home/app/dashboard
ExecStart=/home/app/dashboard/.venv/bin/streamlit run app.py --server.port 8501 --server.address 127.0.0.1
Restart=always

[Install]
WantedBy=multi-user.target
sudo systemctl enable --now dashboard

(Run a Python Script 24/7)

Put Nginx in front for HTTPS and your domain. Streamlit uses WebSockets, so the proxy must pass the upgrade headers — this is the step most guides miss, and without it the app loads a blank page or spins forever:

location / {
    proxy_pass http://127.0.0.1:8501;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    proxy_set_header Host $host;
    proxy_read_timeout 86400;
}

Then add HTTPS with Certbot. (Nginx Reverse Proxy Configuration, Certbot and Let's Encrypt, WebSockets Explained)

Protecting a private app

Streamlit supports built-in OpenID Connect login through st.login(), st.user and st.logout(). Configure the identity provider and [auth] settings in secrets.toml, and stop unauthenticated users before rendering private content. Login identifies the user; your app still needs authorization checks to decide which records they may see. (Streamlit authentication docs) You can also put the app behind your reverse proxy's basic auth, an identity-aware proxy or Cloudflare Tunnel with access rules.

The summary

  • Public demo: Streamlit Community Cloud, free, deployed from GitHub.
  • Private or always-on: your own server with systemd + Nginx.
  • Use st.secrets, a complete requirements.txt, and pass WebSocket headers through Nginx.

EasySpawn runs Streamlit apps on a persistent server that never sleeps, with HTTPS and WebSockets set up for you and Claude Code to build the dashboard itself. See how it works or join the waitlist.

Related: Deploy a Flask App · Deploy a FastAPI App · What Is Python? · Host a Website for Free

Keep reading