Installing Streamlit App on Azure Virtual Machine: A Step-by-Step Guide

Abstract: Resolves connection failures by configuring Azure NSG port 8501 and installing Streamlit dependencies on a VM.

Created: 2026-08-04 by

To install and run a Streamlit app on an Azure Virtual Machine, first ensure the VM has Python 3.7+ installed by connecting via SSH. Then, use pip to install the streamlit package in your desired environment. Finally, launch the application using the streamlit run command while configuring the Azure Network Security Group to allow inbound traffic on port 8501.

Preparing the Azure Virtual Machine

Before diving into the software installation, you must ensure that your Azure Virtual Machine (VM) is properly configured to accept incoming connections. Streamlit applications typically run on port 8501 by default. If this port is blocked by the firewall or network security rules, users will not be able to access your dashboard from their local machines. Start by navigating to the Azure Portal and selecting your virtual machine. Under the "Settings" menu, locate the "Networking" blade. Here, you will see a list of inbound port rules. Click on "Add inbound port rule" and create a new rule with the following specifications:
  • Source: Any (or specify your IP for tighter security)
  • Destination port ranges: 8501
  • Protocol: TCP
  • Action: Allow
  • Name: Allow-Streamlit-Port
This step is critical because many developers forget to open the specific port required by the framework, leading to connection timeouts even after successful installation. Once the rule is applied, your VM is ready to receive traffic on the Streamlit port.

Installing Python and Dependencies

Streamlit requires Python 3.7 or higher. Most modern Azure Linux distributions come with Python pre-installed, but it is best practice to verify the version and install any missing dependencies. Connect to your VM using SSH from your terminal:
ssh username@your-vm-ip-address
Once connected, check your Python version:
python3 --version
If Python is not installed or is outdated, install it using your distribution's package manager. For Ubuntu/Debian systems, use:
sudo apt update
sudo apt install python3-pip python3-dev
For CentOS/RHEL systems, use:
sudo yum install python3 pip
After ensuring Python is available, it is highly recommended to use a virtual environment to isolate your project dependencies. This prevents conflicts with system-wide packages and makes deployment cleaner. Create a virtual environment named env:
python3 -m venv env
source env/bin/activate
With the environment activated, you can proceed to install Streamlit itself. This process is straightforward and relies on pip, the standard package installer for Python. You can refer to our guide on running applications installed via pip for more details on managing executable scripts within virtual environments.

Installing Streamlit

With your virtual environment active, install the Streamlit library by running the following command:
pip install streamlit
This command downloads the latest stable version of Streamlit along with all its core dependencies, such as Flask, Tornado, and NumPy. The installation may take a few minutes depending on your internet connection speed. If your Streamlit app relies on specific data science libraries like Pandas, Matplotlib, or Scikit-learn, install them now while the virtual environment is still active:
pip install pandas matplotlib scikit-learn
Ensuring these dependencies are present before launching the app prevents runtime errors related to missing modules. It is also good practice to freeze your requirements into a requirements.txt file for reproducibility:
pip freeze > requirements.txt

Running the Streamlit Application

Now that the software is installed, you need to serve your application. Place your main Streamlit script, typically named app.py, in a directory on the VM. Navigate to that directory in your SSH session. To start the server, use the streamlit run command followed by the path to your script:
streamlit run app.py
By default, Streamlit binds to localhost (127.0.0.1), which means it is only accessible from within the VM itself. To make it accessible from the outside world, you must explicitly bind it to the public interface. Use the --server.address flag:
streamlit run app.py --server.address 0.0.0.0
The output will display the local URL (http://localhost:8501) and the public URL if detected. Copy the public IP address provided in the terminal output. Open your web browser and navigate to http://your-vm-ip:8501. Your Streamlit dashboard should now be live and interactive.

Managing Long-Running Processes

While the command above works for testing, closing your SSH session will terminate the Streamlit process. To keep the app running in the background, you can use tools like nohup, screen, or systemd services. Using nohup is a simple method for basic setups:
nohup streamlit run app.py --server.address 0.0.0.0 &
This detaches the process from the terminal, allowing it to continue running even after you log out. For production-grade deployments, consider setting up a systemd service unit file to manage startup, shutdown, and automatic restarts on failure.

Troubleshooting Common Issues

If you encounter issues accessing the app, verify the following:
  • Firewall Rules: Ensure port 8501 is open in both the Azure NSG and the OS-level firewall (e.g., ufw or firewalld).
  • Virtual Environment: Confirm that the virtual environment is activated when running the streamlit run command. Installed packages inside an inactive venv will not be found.
  • Permissions: Ensure the user running the command has read access to the app.py file.

Frequently Asked Questions

Can I run multiple Streamlit apps on the same VM?

Yes, you can run multiple apps simultaneously by assigning each app a different port number. Use the --server.port flag when launching each instance, such as --server.port 8502 for the second app, and ensure those ports are also allowed in your Azure Network Security Group.

How do I secure my Streamlit app with HTTPS?

Streamlit supports SSL certificates directly. You can enable HTTPS by providing the paths to your certificate and key files using the --server.sslCertFile and --server.sslKeyFile flags during the streamlit run command. Alternatively, place a reverse proxy like Nginx in front of Streamlit to handle SSL termination.

What should I do if I get a "ModuleNotFoundError" after installation?

This error usually indicates that the virtual environment was not activated when you ran the Streamlit command. Deactivate the current shell, activate your virtual environment again using source env/bin/activate, and then re-run the streamlit run command to ensure it uses the correct isolated Python environment.

Is it possible to install Streamlit alongside Node.js on the same VM?

Yes, Python and Node.js can coexist on the same Azure VM without conflict. They use different binary paths and package managers. However, be mindful of resource allocation, as both environments consume RAM and CPU. Refer to our guide on installing Python in a different directory for Node.js if you need to manage separate global installations cleanly.

Why is my Streamlit app slow to load initially?

The first load might be slower due to cold starts or large dependency imports. Ensure you are not importing heavy libraries inside the global scope if they are not needed immediately. Additionally, check if your VM has sufficient memory and CPU allocated; small VM sizes may struggle with data processing tasks in real-time.

Latest News

How to Display Output of xterm Command in Terminal Screen using Cron

Resolve the inability to display xterm output in a terminal screen from cron by redirecting logs or using wall instead of insecure X11 workarounds.

Read More
Expose Local Server on VPS Preserving Real Client IPs (OS Level)

Resolve VPS logging showing only gateway IPs by configuring reverse proxies to forward real client addresses via X-Forwarded-For headers.

Read More
How to Clear Recent Files History in Linux without Deleting Actual Files?

Clear recent files history in Linux by deleting ~/.local/share/recently-used.xbel without removing the actual files.

Read More
Best HDD Copy Strategy: Manually Syncing and Rewriting Scratch

Resolve data drift between two 4TB hard drives by using rsync with the --delete flag to manually sync and rewrite scratch data for an exact mirror.

Read More
Understanding Bash Prompt Abbreviations: An Overview

Resolve repetitive typing errors by creating and persisting Bash aliases in the .bashrc file for improved command-line efficiency.

Read More
Free Tools and Methods to Log Real-Time Performance Details in Task Manager

Log real-time CPU and memory metrics to CSV files using Windows Performance Monitor Data Collector Sets to troubleshoot system slowness.

Read More
Contact Qatar Airways Customer Service: Phone Number, Help Center, and More

Resolve urgent Qatar Airways reservation issues like flight changes and baggage claims using the US phone number +1801-855-5905 or online self-service tools.

Read More
Windows 11: Alt Codes Displaying Wrong Characters - Solutions

Resolve Windows 11 Alt codes showing wrong characters by verifying the US keyboard layout and enabling Num Lock.

Read More
Run Programs with Elevated Privileges: A Comprehensive Guide

Eliminates the need to type sudo for frequent administrative tasks by configuring .bashrc aliases or functions.

Read More
Dynamically Changing Dates in Excel Formulas Using Cells

Eliminate manual date updates in Excel by using cell references to create dynamic formulas that automatically adjust calculations when input dates change.

Read More
Granting Edit Access to a Specific Excel Sheet in an Office 365 User Email ID-Based Login

Excel Online lacks native sheet-level permissions, so users must split workbooks or use worksheet protection to isolate edit access for specific tabs.

Read More
Creating Network Load on Local Wi-Fi from One PC

Generate sustained Wi-Fi bandwidth load from a single PC using a VM SFTP server to test router stability and throughput.

Read More
Changing the Default Editor for Batch Files in Windows 11's File Explorer

Resolve the issue of batch files opening in Notepad by changing the default editor to a preferred application like VS Code.

Read More
Gain WiFi Connection Minutes Before Losing it by Changing MAC Address

Bypass MAC address filtering to restore WiFi connectivity temporarily when a device is blocked by network administrators.

Read More
Photos Folders Turned Black: Troubleshooting Picture Applications on Windows

Resolve black screens in Windows Photos by resetting the app, updating graphics drivers, and repairing system files.

Read More
Troubleshooting High CPU Temperature Values: A Step-by-Step Guide

Resolve high CPU temperatures and thermal throttling by monitoring with Speedfan, cleaning dust from cooling components, and replacing degraded thermal paste.

Read More
Make cURL establish TLS connection with CA unknown

Resolve cURL TLS connection failures with unknown or self-signed certificates by using the --insecure flag to bypass CA validation.

Read More
Troubleshooting Incorrect Network Metrics Values in Grafana, Prometheus, InfluxDB, and Telegraf

Fix incorrect network metrics in Grafana, Prometheus, InfluxDB, and Telegraf by verifying interface selection, resolving unit mismatches, and handling counter resets.

Read More
Start Another Terminal Window (cmd.exe) Windows Repair/Troubleshoot

Provides step-by-step instructions to access the Windows Command Prompt via bootable media for advanced system repair and troubleshooting.

Read More
Thinkpad P1 Gen 6: Sudden Thunderbolt 3 Dock USB-C Charging Stopped Working

Resolve sudden Thunderbolt 3 dock USB-C charging and internet failure on ThinkPad P1 Gen 6 by updating firmware, resetting the dock, and adjusting power settings.

Read More
ASUS Windows 11 Laptop: Internet Connection Issue with Hotspot

Resolve ASUS Windows 11 laptop spinning wheel issue when connecting to mobile hotspot by resetting network stack, disabling IPv6, and adjusting power settings.

Read More
Developing iOS Project with Firebase: Logging in and Sending Push Notifications

Integrates Firebase to enable secure user authentication and push notifications in iOS applications.

Read More
Troubleshooting Bash Script with Suspected Issues of Spaces, Dashes, Filenames and Quoting

Resolve Bash script failures caused by word splitting, globbing, and special characters in filenames by applying proper quoting techniques.

Read More
Populating OneDrive Folder for Local Backup without Affecting Remote Files

Prevent OneDrive from deleting remote files during Windows reinstallation by unlinking the account or using symbolic links to isolate local data.

Read More
Force First Frame as Keyframe Without Re-encoding: A Quick Solution

Resolve inaccurate seeking and playback glitches by re-encoding video to ensure the first frame is a valid keyframe.

Read More
Find Information in Database Using WSL (Ubuntu) on Windows-10

Resolve database connection issues from WSL Ubuntu on Windows 10 by configuring client tools and network access to query remote or local servers.

Read More
Configuring a New Router with Different Networks: One Family, One Guest

Resolve IP conflicts and isolate guest traffic by configuring a second router with a distinct subnet via its WAN port.

Read More
Quickly Open Multiple Stock Websites with a Single Command

Solve the problem of manually opening multiple stock research websites by creating a single command to launch them simultaneously on Windows, macOS, or Linux.

Read More
Improved Adobe Acrobat Search Experience: Access Advanced Search with Ease

Access advanced search filters like case sensitivity and regex in Adobe Acrobat by clicking More Options in the Find bar.

Read More
Port Forwarding VM via OpenVPN: A Comprehensive Guide

Configure OpenVPN server and iptables to forward specific ports from VPN clients to a virtual machine's internal IP address.

Read More
Understanding Partitions in the 1980s: A Look Back at MS-DOS and Master Boot Record

Explains how the Master Boot Record and partition table enabled MS-DOS to manage multiple disk volumes on a single physical drive.

Read More
Windows 10 Enterprise: Keyboard Not Detected in Managed Organization with Admin Privileges

Resolve Windows 10 Enterprise keyboard detection failures caused by Group Policy restrictions, driver corruption, or USB enumeration errors.

Read More
Can't Find x86_64 Versions of Applications on MacOS arm64 (M1)

Resolve missing x86_64 app issues on M1 Macs by installing Rosetta 2 and reinstalling apps as universal binaries.

Read More
How to Hide Installation Source for an Android App

Manage Android app installation source visibility by using USB transfers or file managers to reduce browser traces and isolate data via work profiles.

Read More
Connecting Momentus 4200.2 ST9808210A Hard Drive via USB Cable

Resolve inability to access Seagate Momentus 4200.2 ST9808210A hard drive by connecting it via USB using a compatible SATA-to-USB adapter and configuring the disk in Windows.

Read More