Skip to content

Docusaurus doesn't respect the $PORT environment variable #8681

@seyoon20087

Description

@seyoon20087

**NOTE: If you believe this is a question please convert it to a discussion (rather than closing it), cf https://bit.ly/3YWp3GJ

Have you read the Contributing Guidelines on issues?

Prerequisites

  • I'm using the latest version of Docusaurus.
  • I have tried the npm run clear or yarn clear command.
  • I have tried rm -rf node_modules yarn.lock package-lock.json and re-installing packages.
  • I have tried creating a repro with https://new.docusaurus.io.
  • I have read the console error message carefully (if applicable).

Description

Docusaurus is not respecting the $PORT environment variable.

For example if I specify env PORT=8000 yarn start it will start on port 3000 and not on 8000.

Reproducible demo

https://github.com/seyoon20087/docusaurus-reproduction-port-env-not-respecting

Steps to reproduce

  1. Clone that repository
  2. Install dependencies (yarn)
  3. Attempt to start the server at port 8000, using env PORT=8000 yarn start
  4. The server will start at port 3000 and not 8000

Expected behavior

I expected that the server should start in the port on the $PORT environment variable specified

Actual behavior

The server will start on 3000 if I don't use --port option.
This is different from other frameworks (like Next.js), which they respect the $PORT environment variable.

For your reference here is the screenshot:
image

Your environment

  • Public source code: https://github.com/seyoon20087/docusaurus-reproduction-port-env-not-respecting
  • Public site URL: Not relevant
  • Docusaurus version used: 2.3.1 -- note that this issue applies to any current Docusaurus version
  • Environment name and version (e.g. Chrome 89, Node.js 16.4): Node.js 16.19.0
  • Operating system and version (e.g. Ubuntu 20.04.2 LTS): Gitpod (Ubuntu 20.04.5 container)

Self-service

  • I'd be willing to fix this bug myself.

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureThis is not a bug or issue with Docusausus, per se. It is a feature request for the future.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions