Configuring Your Application's Port
Seenode automatically routes traffic from the internet to your running web service. To ensure your application can receive this traffic, it must listen on the correct port.
The $PORT
Environment Variable
Section titled “The $PORT Environment Variable”Seenode automatically injects a $PORT
environment variable into your service’s environment. Your application must listen on the host 0.0.0.0
and the port specified by this environment variable to receive incoming connections from our load balancer.
You do not need to set the port in your application’s settings on the Seenode dashboard. Seenode handles this for you. Your code just needs to read the $PORT
variable.
How Routing Works
Section titled “How Routing Works”- A user sends a request to your application’s public URL (e.g.,
https://my-app.seenode.app
). - The request hits Seenode’s load balancer on port 80 (for HTTP) or 443 (for HTTPS).
- The load balancer forwards the request to your application’s container on the port defined by the
$PORT
environment variable.
Example: Configuring a Flask App
Section titled “Example: Configuring a Flask App”Here’s how to correctly configure a simple Flask application to work with Seenode’s environment.
-
Read the
$PORT
variable in your codeModify your application to read the
PORT
from the environment. Provide a default value for local development.app.py import osfrom flask import Flaskapp = Flask(__name__)# Get port from environment variable or default to 5000port = int(os.environ.get("PORT", 5000))@app.route('/')def hello_world():return 'Hello, World!'if __name__ == '__main__':app.run(host='0.0.0.0', port=port) -
Ensure your start command is correct
Your start command should simply run the application.
Terminal window python app.pyFor a production application, you would use a production server like Gunicorn and bind it to the correct host and port.
Terminal window gunicorn app:app --bind 0.0.0.0:$PORT
By following this pattern, your application will work seamlessly with Seenode’s automatic routing and port management, both in production and during local development.
How routing works
Section titled “How routing works”Every web services come with default domain, optionally you an set a custom domain. All requests pass through our load balancer as follows:
Let’s say your app starts and listen for requests on port 4000
Our load balancer is configured such that that every request coming to your app on port 443
or 80
are proxied to port 4000
of your app

Examples
Section titled “Examples”Web Service Name | Public Connection | Private Connection |
---|---|---|
web-abcdefgh | https://web-abcdefgh.up-de-fra1-k8s-1.apps.run-on-seenode.com | http://web-abcdefgh-service |
Flask example:
Section titled “Flask example:”- Let’s say your app is configured to start on port
4000
app.py
from flask import Flask
app = Flask(__name__)
@app.route('/')def hello(): return "Hello, World!"
if __name__ == "__main__": app.run(host="0.0.0.0", port=4000)
- Set the port to
4000

-
Follow the next steps by clicking continue
-
Now when the app is built and deployed successfully you can connect to your app by:
a. Public connection domain (user for access from the internet)
b. Private connection domain (use for internal connections between your services)