12 Factor App

Twelve Factor App methodology

Port Binding

Accessing our Flask web application is as straightforward as entering the URL along with the port number into your web browser. In our example, the application runs on port 5000. When accessed successfully, a welcome message along with a visitor count is displayed.

A browser window displays a message: "Welcome to KODEKLOUD! Visitor Count: 10" on a localhost server.

By default, the Python Flask framework listens on port 5000. However, when running multiple instances of the application on the same server, each instance can bind to a unique port (such as 5001, 5002, etc.). In multi-service environments, different services are assigned distinct ports—for instance, Redis typically operates on port 6379.

The image shows a network diagram with four nodes labeled 5001, 5000, 5002, and 6379, featuring globe and database icons.

Binding an application to a specific port allows it to export HTTP as a service and listen directly for incoming requests. In contrast to traditional web applications that depend on an external web server, the 12-Factor App methodology encourages creating self-contained applications with built-in web servers. This design approach not only simplifies deployment but also enhances scalability.

Note

For environments that host multiple services simultaneously, ensuring each service is bound to a unique port is crucial for preventing conflicts and maintaining smooth communication between services.

Watch Video

Watch video content

Previous
Build Release and Run