Skip to content

fix: respect HOST when selecting port - #124

Closed
joniilmanfahmi00-collab wants to merge 1 commit into
adonisjs:8.xfrom
joniilmanfahmi00-collab:fix/get-port-host
Closed

joniilmanfahmi00-collab wants to merge 1 commit into
adonisjs:8.xfrom
joniilmanfahmi00-collab:fix/get-port-host

Conversation

@joniilmanfahmi00-collab

Copy link
Copy Markdown

Summary

Fixes an issue where getPort() could select a random port even when the configured PORT was available on the configured HOST.

Previously, getRandomPort() was called without a host option, causing port availability checks to consider other local interfaces.

Changes

  • Pass process.env.HOST when resolving PORT from process environment variables.
  • Pass envVariables.HOST when resolving PORT from .env files.
  • Add regression tests covering both environment variable and .env configurations.

Testing

  • Focused tests: 6 passed.
  • Full test suite: 299 passed.
  • git diff --check: passed.

Closes #115

@thetutlage thetutlage added status: incoming The status of the hub task status: ready The status of the hub task and removed status: incoming The status of the hub task labels Nov 16, 2026
@fleet-panda fleet-panda Bot added status: building The status of the hub task and removed status: ready The status of the hub task labels Nov 16, 2026
@fleet-panda fleet-panda Bot added status: review The status of the hub task status: accepting The status of the hub task and removed status: building The status of the hub task status: review The status of the hub task labels Nov 16, 2026
@fleet-panda

fleet-panda Bot commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

Thank you for this fix, @joniilmanfahmi00-collab. Your commit is part of #126, which is now merged. That pull request also reads HOST from process.env and the .env files in the order the app reads them, and passes it for the default port 3333 too.

@fleet-panda fleet-panda Bot closed this Nov 16, 2026
@fleet-panda fleet-panda Bot added status: done The status of the hub task and removed status: accepting The status of the hub task labels Nov 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: done The status of the hub task

Projects

None yet

Development

Successfully merging this pull request may close these issues.

getPort ignores HOST, so a port in use on another interface forces a random PORT

3 participants