diff --git a/src/docs/guides/fixing-common-errors.md b/src/docs/guides/fixing-common-errors.md index eb1be6f96..dd3bed9ae 100644 --- a/src/docs/guides/fixing-common-errors.md +++ b/src/docs/guides/fixing-common-errors.md @@ -93,6 +93,7 @@ async function bootstrap() { #### Node / Next Next needs an additional flag to listen on `PORT`: + ```bash next start --port ${PORT-3000} ``` @@ -100,15 +101,15 @@ next start --port ${PORT-3000} #### Python / Gunicorn `gunicorn` listens on `0.0.0.0` and the `PORT` environment variable by default: + ```bash gunicorn main:app ``` -There is no additional configuration necessary. - #### Python / Uvicorn `uvicorn` needs additional configuration flags to listen on `0.0.0.0` and `PORT`: + ```bash uvicorn main:app --host 0.0.0.0 --port $PORT ``` @@ -139,4 +140,4 @@ When an HTTP client encounters a 301 Moved Permanently redirect, the client will ### Solution -Fortunately, the solution is simple: Ensure you are using HTTPS when calling your Railway-hosted services. \ No newline at end of file +Fortunately, the solution is simple: Ensure you are using HTTPS when calling your Railway-hosted services. diff --git a/src/docs/guides/private-networking.md b/src/docs/guides/private-networking.md index c710754f9..57d5f564d 100644 --- a/src/docs/guides/private-networking.md +++ b/src/docs/guides/private-networking.md @@ -17,9 +17,13 @@ To communicate over the private network, there are some specific things to know ### Listen on IPv6 -Since the private network is an IPv6 network, applications that will receive requests over the private network must be configured to listen on IPv6. On most web frameworks, you can do this via `::` and specifying the port(s) to which you want to bind. +Since the private network is an IPv6 only network, applications that will receive requests over the private network must be configured to listen on IPv6. On most web frameworks, you can do this by binding to the host `::`. -For example - +Some examples are below - + +#### Node / Express + +Listen on `::` to bind to both IPv4 and IPv6. ```javascript const port = process.env.PORT || 3000; @@ -29,6 +33,64 @@ app.listen(port, '::', () => { }); ``` +#### Node / Nest + +Listen on `::` to bind to both IPv4 and IPv6. + +```javascript +const port = process.env.PORT || 3000; + +async function bootstrap() { + await app.listen(port, '::'); +} +``` + +#### Node / Next + +Update your start command to bind to both IPv4 and IPv6. + +```bash +next start --hostname :: --port ${PORT-3000} +``` + +Or if you are using a custom server, set `hostname` to `::` in the configuration object passed to the `next()` function. + +```javascript +const port = process.env.PORT || 3000; + +const app = next({ + // ... + hostname: '::', + port: port +}); +``` + +If neither of these options are viable, you can set a `HOSTNAME` [service variable](/guides/variables#service-variables) with the value `::` to listen on both IPv4 and IPv6. + +#### Python / Gunicorn + +Update your start command to bind to both IPv4 and IPv6. + +```bash +gunicorn app:app --bind [::]:${PORT-3000} +``` + +#### Python / Hypercorn + +Update your start command to bind to both IPv4 and IPv6. + +```bash +hypercorn app:app --bind [::]:${PORT-3000} +``` + +#### Python / Uvicorn + +Update your start command to bind to IPv6. + +```bash +uvicorn app:app --host :: --port ${PORT-3000} +``` + **Note:** If your application needs to be accessible over both private and public networks, your application server must support dual stack binding. Most servers handle this automatically when listening on `::`, but some, like Uvicorn, do not. ### Use Internal Hostname and Port