Open Editor →

Ports & Networking

Understand how Python Online bridges the gap between your public URL and your containerized application, eliminating 502 Bad Gateway errors.

The Port Mapping Problem

One of the most common challenges in web deployment is connecting the internet to the specific "door" (port) your application is listening on. Different Python frameworks expect traffic on different ports by default.

If our cloud infrastructure routes traffic to port 8000, but your Flask app is waiting at port 5000, visitors will hit a dead end and receive a 502 Bad Gateway error.

Common Framework Ports

Frameworks Default Port
FastAPI, Django, Sanic, Litestar, Falcon, Masonite, Flet 8000
AIOHTTP, Bottle, Pyramid, NiceGUI 8080
Flask 5000
Streamlit 8501
Dash (Plotly) 8050
Panel 5006
Tornado 8888
Reflex 3000

The Custom Port Solution

Rather than forcing you to rewrite your code to match our infrastructure, Python Online adapts to match your code.

In the Hosting Dashboard, you will find an Internal Port field. Simply type in the number your framework expects (e.g., 5000 for Flask). When you click deploy, our routing engine automatically forwards all public HTTPS traffic precisely to the door you specified.

The Localhost Problem

Even if the port matches perfectly, deployments often fail due to network binding restrictions. When you run a Python web app on your laptop, it usually listens for traffic on localhost (also known as 127.0.0.1).

This is a security feature built into most development frameworks to prevent people on your local Wi-Fi from accessing your app while you are building it. However, when you move that code to a cloud server, that same security feature blocks the public internet from reaching your app, resulting in another 502 error.

On traditional hosting platforms, fixing this requires rewriting your code or learning new command-line flags (like appending --host 0.0.0.0) to explicitly tell your app to listen to the outside world.

Python Online eliminates this headache. Our infrastructure automatically bridges the gap between the public internet and your app's local environment in the background.

The Result: You don't need to change your code or add special host flags. If your app runs successfully on your laptop using localhost, it will run exactly the same way here, and we guarantee the world can securely reach it.

WebSocket Support

Modern interactive applications often require persistent two-way communication between the browser and the server. Python Online natively supports WebSockets right out of the box.

Frameworks that rely heavily on WebSockets (like FastAPI, Socket.IO, Streamlit, and NiceGUI) will function perfectly over your main HTTPS connection without requiring secondary ports or complex proxy configurations.