Ports

Application Ports

Kinsta automatically sets the PORT environment variable. You do not need to define it or hard-code it into the application. Use the PORT environment variable to refer to the port in your application.

When you deploy the application, it will be reachable on the internet on ports 80 and 443, and we will route those ports to the container on the port specified within your web process.

You can define a port for your application web process when you add the application or within Networking > Edit port. The port must be within the range 1-65535 except for the following ports used by our core system: 15000, 15001, 15004, 15006, 15008, 15009, 15020, 15021, 15053, and 15090.

PORT Environment Variable Language Examples

How you use an environment variable is up to your application. The following table shows how to call the PORT environment variable in various languages:

LanguageCode
RubyENV["PORT"]
Node.jsprocess.env.PORT;
Pythonos.environ.get('PORT')
JavaSystem.getenv("PORT");
ScalaSystem.getenv("PORT");
PHPgetenv('PORT');
Goos.Getenv("PORT")

Database Ports

Only the port shown in Info > External connections is open for Database Hosting. To connect the database to an external application, use the port and other external connection details shown there.

If you are connecting an application and database that are both hosted on Kinsta, make sure they use the same data center location and are connected by an internal connection.

Was this article helpful?