Unverified Commit e9cc67df authored by Sam Ko's avatar Sam Ko Committed by GitHub

docs(cli): add mention of our default port behavior (#62964)

## Changes

- We need to document how that we retry until a port is found when we're
not specifying a port via the CLI (`--port`) or the `PORT` environment
variable. For example, if `3000` and `3001` are used, we will check
`3000`, `3001`, and then land on `3002`.

Closes NEXT-2731
parent 41cb6c48
...@@ -101,7 +101,10 @@ Or using the `PORT` environment variable: ...@@ -101,7 +101,10 @@ Or using the `PORT` environment variable:
PORT=4000 next dev PORT=4000 next dev
``` ```
> **Good to know**: `PORT` cannot be set in `.env` as booting up the HTTP server happens before any other code is initialized. > **Good to know**:
>
> - `PORT` cannot be set in `.env` as booting up the HTTP server happens before any other code is initialized.
> - Next.js will automatically retry with another port until a port is available if a port is not specified with the CLI option `--port` or the `PORT` environment variable.
You can also set the hostname to be different from the default of `0.0.0.0`, this can be useful for making the application available for other devices on the network. The default hostname can be changed with `-H`, like so: You can also set the hostname to be different from the default of `0.0.0.0`, this can be useful for making the application available for other devices on the network. The default hostname can be changed with `-H`, like so:
...@@ -273,8 +276,7 @@ PORT=4000 next start ...@@ -273,8 +276,7 @@ PORT=4000 next start
> **Good to know**: > **Good to know**:
> >
> -`PORT` cannot be set in `.env` as booting up the HTTP server happens before any other code is initialized. > - `PORT` cannot be set in `.env` as booting up the HTTP server happens before any other code is initialized.
>
> - `next start` cannot be used with `output: 'standalone'` or `output: 'export'`. > - `next start` cannot be used with `output: 'standalone'` or `output: 'export'`.
### Keep Alive Timeout ### Keep Alive Timeout
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment