Fixing Common Errors

When deploying to Railway, you may encounter some errors that prevent your application from working. These are descriptions and solutions to errors that users commonly encounter.

Application Error: This application failed to respond

After deploying your application, you encounter this screen when accessing your application's domain:

Screenshot of application failed to respond error

This error occurs when Railway is unable to connect to your application, making your request fail with status code 503 (Bad Gateway).

Railway needs to know how to communicate with your application. When you deploy and expose a web application on Railway, we expect your web server to be available at host 0.0.0.0 and a port that we provide in the form of a PORT variable. The PORT variable is automatically injected by Railway into your application's environment.

Thus, your web server must listen on host 0.0.0.0 and the port that Railway provides in the PORT environment variable.

Solution

To fix this, start your application's server using:

  • Host = 0.0.0.0,
  • Port = Value of the PORT environment variable provided by Railway.

Below are some solution examples for common languages and frameworks.

Node / Express

Node / Nest

Node / Next

Next needs an additional flag to listen on PORT:

Python / Gunicorn

gunicorn listens on 0.0.0.0 and the PORT environment variable by default:

There is no additional configuration necessary.

Python / Uvicorn

uvicorn needs additional configuration flags to listen on 0.0.0.0 and PORT:

Go / net/http

This example is for net/http in the Go standard library, but you can also apply this to other frameworks:


Edit this file on GitHub