By Ferd
I have a streamlit app in droplet. It worked using the ip address. To run the app I would go to console and type “streamlit run myapp.py”.
How do I deploy it so that I don’t have to type “streamlit run myapp.py” on the console?
Thanks for the help.
Other questions for the next step.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Heya @ferdinandmosca,
You should be able to deploy this using PM2 so that you don’t have to constantly type in streamlit run myapp.py.
Additionally, in order to setup a domain and run it on https, I’ll recommend using Nginx as a reverse proxy.
PM2 is a process manager for Node.js applications, but it can also be used to manage other types of applications, including Python apps like Streamlit.
sudo apt update
sudo apt install nodejs npm
sudo npm install pm2@latest -g
pm2 start 'streamlit run myapp.py' --name my-streamlit-app
The --name flag is optional but helps identify the process.
pm2 startup
pm2 save
Nginx can be used to reverse proxy your Streamlit app, making it accessible via a standard web port (like 80 for HTTP).
sudo apt update
sudo apt install nginx
sudo nano /etc/nginx/sites-available/default
Add the following inside the server block:
location / {
proxy_pass http://localhost:8501; # Ensure this is the port Streamlit runs on
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
}
systemctl restart nginx
Setup Domain:
server_name directive.Enable HTTPS with Let’s Encrypt:
sudo apt install certbot python3-certbot-nginx
sudo certbot --nginx -d yourdomain.com -d www.yourdomain.com
This setup should ensure your Streamlit app is running continuously without manual intervention, accessible through a domain name, and secured with HTTPS.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.