Skip to content

Environment Variable Name Conflict in Deployments #131

@DevStarlight

Description

@DevStarlight

When deploying applications with container orchestration systems, certain environment variable names are reserved by the system and cannot be used. The current configuration uses PORT which is one of these reserved names, causing deployment failures and automatic rollbacks.

Best Practices

It's generally considered bad practice to use common system names like PORT, HOST, PATH, etc. for custom environment variables, as they can conflict with system internals.

Suggested Solutions

Option 1: Rename the variable
Change PORT to one of these alternatives:

  • APP_PORT
  • SERVER_PORT
  • LISTEN_PORT

Option 2: Legacy support
Keep PORT as default but set by default a port number.

const port = process.env.PORT || 3000;

Option 3: Extended legacy support
Keep PORT as default but allow overriding with a custom name, maintaining backward compatibility

const port = process.env.PORT || process.env.<APP_PORT | SERVER_PORT | LISTEN_PORT> || 3000;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions