Skip to content

fix(install): check ports 8080 and 18789 are free before starting gateway - #357

Closed
webdevpraveen wants to merge 1 commit into
NVIDIA:mainfrom
webdevpraveen:fix/preflight-port-conflict-check
Closed

webdevpraveen wants to merge 1 commit into
NVIDIA:mainfrom
webdevpraveen:fix/preflight-port-conflict-check

Conversation

@webdevpraveen

Copy link
Copy Markdown
Contributor

Fixes #51

install.sh starts the OpenShell gateway on port 8080 and the OpenClaw dashboard on port 18789 without checking whether those ports are already in use. Users with existing Docker containers or other services on those ports get a cryptic startup failure with no actionable guidance.

Problem

When a port is occupied, the installer fails deep in gateway startup with no clear message:

Error: listen tcp 0.0.0.0:8080: bind: address already in use

There is no named error, no suggestion to check ports, and no way to override without editing the script.

Fix

Adds check_required_ports() to the [1/7] Preflight checks step, before any gateway or sandbox setup begins:

  • Detects conflicts using ss (iproute2) with netstat as fallback
  • Prints a clear, named error identifying the conflicting port and service
  • Documents NEMOCLAW_GATEWAY_PORT and NEMOCLAW_DASHBOARD_PORT env-var overrides so users can switch ports without stopping existing services
  • Degrades gracefully (warns only) when neither ss nor netstat is available

Example output when a port is occupied

[ERROR] Port 8080 (gateway) is already in use.
[ERROR]   Check: ss -tlnp | grep :8080
[ERROR]   Override: export NEMOCLAW_GATEWAY_PORT=<free-port>
[ERROR] Free conflicting ports (or override via env vars) then re-run.

…eway

Fixes NVIDIA#51

install.sh starts the OpenShell gateway on port 8080 and the OpenClaw
dashboard on port 18789 without checking whether those ports are
already in use. Users with existing Docker containers, web servers,
or other services on those ports get a cryptic startup failure:

  Error: listen tcp 0.0.0.0:8080: bind: address already in use

This change adds a check_required_ports() preflight function that
runs before any gateway or sandbox setup:

- Detects conflicts using ss (iproute2) with netstat fallback
- Prints a clear, named error identifying the conflicting port
- Suggests NEMOCLAW_GATEWAY_PORT / NEMOCLAW_DASHBOARD_PORT env vars
  so users can override without stopping existing services
- Degrades gracefully when neither ss nor netstat is available

Signed-off-by: webdevpraveen <[email protected]>
mafueee pushed a commit to mafueee/NemoClaw that referenced this pull request Mar 28, 2026
@prekshivyas prekshivyas assigned prekshivyas and unassigned kjw3 Apr 8, 2026
cv added a commit that referenced this pull request Apr 13, 2026
…1645)

## Summary

- Add `bin/lib/ports.js` as central port configuration module
- All hardcoded service ports can now be overridden via environment
variables
- Defaults are unchanged — zero regression for existing setups

| Env var | Default | Service |
|---------|---------|---------|
| `NEMOCLAW_GATEWAY_PORT` | 8080 | OpenShell gateway |
| `NEMOCLAW_DASHBOARD_PORT` | 18789 | Dashboard UI |
| `NEMOCLAW_VLLM_PORT` | 8000 | vLLM/NIM inference |
| `NEMOCLAW_OLLAMA_PORT` | 11434 | Ollama inference |

Ports are validated to be non-privileged (1024–65535).

### Usage

```bash
export NEMOCLAW_DASHBOARD_PORT=19000
nemoclaw onboard
```

## Related Issue

Closes #684
Based on the approach from PR #683 by @jnun — thank you for the original
design.

Supersedes #683 (rebased on latest main with correct defaults).
Consider closing #703, #357 (subsumed by this).

## Test plan

- [ ] `npm test` passes (135 tests in cli + onboard)
- [ ] `nemoclaw onboard` works with default ports (no regression)
- [ ] Set `NEMOCLAW_DASHBOARD_PORT=19000`, verify dashboard uses port
19000
- [ ] Set invalid port (e.g., `NEMOCLAW_GATEWAY_PORT=abc`), verify
startup fails with clear error

Signed-off-by: Prekshi Vyas <[email protected]>

🤖 Generated with [Claude Code](https://claude.com/claude-code)

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **New Features**
* Centralized, configurable ports for dashboard, gateway, vLLM and
Ollama via environment variables with validated defaults.

* **Improvements**
* Startup, health checks, diagnostics, uninstall and helper flows now
honor configured ports and enforce numeric/range validation with
fail-fast errors.

* **Tests**
* Added unit and end-to-end tests covering port parsing, boundaries and
override scenarios; CI job added to run E2E port-override tests.

* **Chore**
* Added compatibility shim to surface built artifacts and documented the
default dashboard port in the container build.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Signed-off-by: Prekshi Vyas <[email protected]>
Signed-off-by: Aaron Erickson <[email protected]>
Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: jnun <[email protected]>
Co-authored-by: Claude Opus 4.6 (1M context) <[email protected]>
Co-authored-by: Carlos Villela <[email protected]>
Co-authored-by: Aaron Erickson <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
@prekshivyas

Copy link
Copy Markdown
Collaborator

Closing — the port-free checks and configurable overrides are now covered by #1645. The preflight step validates port availability with actionable error messages, and all four service ports can be overridden via environment variables. Thank you for the contribution!

ericksoa added a commit to cheese-head/NemoClaw that referenced this pull request Apr 14, 2026
…VIDIA#1645)

## Summary

- Add `bin/lib/ports.js` as central port configuration module
- All hardcoded service ports can now be overridden via environment
variables
- Defaults are unchanged — zero regression for existing setups

| Env var | Default | Service |
|---------|---------|---------|
| `NEMOCLAW_GATEWAY_PORT` | 8080 | OpenShell gateway |
| `NEMOCLAW_DASHBOARD_PORT` | 18789 | Dashboard UI |
| `NEMOCLAW_VLLM_PORT` | 8000 | vLLM/NIM inference |
| `NEMOCLAW_OLLAMA_PORT` | 11434 | Ollama inference |

Ports are validated to be non-privileged (1024–65535).

### Usage

```bash
export NEMOCLAW_DASHBOARD_PORT=19000
nemoclaw onboard
```

## Related Issue

Closes NVIDIA#684
Based on the approach from PR NVIDIA#683 by @jnun — thank you for the original
design.

Supersedes NVIDIA#683 (rebased on latest main with correct defaults).
Consider closing NVIDIA#703, NVIDIA#357 (subsumed by this).

## Test plan

- [ ] `npm test` passes (135 tests in cli + onboard)
- [ ] `nemoclaw onboard` works with default ports (no regression)
- [ ] Set `NEMOCLAW_DASHBOARD_PORT=19000`, verify dashboard uses port
19000
- [ ] Set invalid port (e.g., `NEMOCLAW_GATEWAY_PORT=abc`), verify
startup fails with clear error

Signed-off-by: Prekshi Vyas <[email protected]>

🤖 Generated with [Claude Code](https://claude.com/claude-code)

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **New Features**
* Centralized, configurable ports for dashboard, gateway, vLLM and
Ollama via environment variables with validated defaults.

* **Improvements**
* Startup, health checks, diagnostics, uninstall and helper flows now
honor configured ports and enforce numeric/range validation with
fail-fast errors.

* **Tests**
* Added unit and end-to-end tests covering port parsing, boundaries and
override scenarios; CI job added to run E2E port-override tests.

* **Chore**
* Added compatibility shim to surface built artifacts and documented the
default dashboard port in the container build.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Signed-off-by: Prekshi Vyas <[email protected]>
Signed-off-by: Aaron Erickson <[email protected]>
Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: jnun <[email protected]>
Co-authored-by: Claude Opus 4.6 (1M context) <[email protected]>
Co-authored-by: Carlos Villela <[email protected]>
Co-authored-by: Aaron Erickson <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
ColinM-sys pushed a commit to ColinM-sys/NemoClaw that referenced this pull request Apr 14, 2026
…VIDIA#1645)

## Summary

- Add `bin/lib/ports.js` as central port configuration module
- All hardcoded service ports can now be overridden via environment
variables
- Defaults are unchanged — zero regression for existing setups

| Env var | Default | Service |
|---------|---------|---------|
| `NEMOCLAW_GATEWAY_PORT` | 8080 | OpenShell gateway |
| `NEMOCLAW_DASHBOARD_PORT` | 18789 | Dashboard UI |
| `NEMOCLAW_VLLM_PORT` | 8000 | vLLM/NIM inference |
| `NEMOCLAW_OLLAMA_PORT` | 11434 | Ollama inference |

Ports are validated to be non-privileged (1024–65535).

### Usage

```bash
export NEMOCLAW_DASHBOARD_PORT=19000
nemoclaw onboard
```

## Related Issue

Closes NVIDIA#684
Based on the approach from PR NVIDIA#683 by @jnun — thank you for the original
design.

Supersedes NVIDIA#683 (rebased on latest main with correct defaults).
Consider closing NVIDIA#703, NVIDIA#357 (subsumed by this).

## Test plan

- [ ] `npm test` passes (135 tests in cli + onboard)
- [ ] `nemoclaw onboard` works with default ports (no regression)
- [ ] Set `NEMOCLAW_DASHBOARD_PORT=19000`, verify dashboard uses port
19000
- [ ] Set invalid port (e.g., `NEMOCLAW_GATEWAY_PORT=abc`), verify
startup fails with clear error

Signed-off-by: Prekshi Vyas <[email protected]>

🤖 Generated with [Claude Code](https://claude.com/claude-code)

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **New Features**
* Centralized, configurable ports for dashboard, gateway, vLLM and
Ollama via environment variables with validated defaults.

* **Improvements**
* Startup, health checks, diagnostics, uninstall and helper flows now
honor configured ports and enforce numeric/range validation with
fail-fast errors.

* **Tests**
* Added unit and end-to-end tests covering port parsing, boundaries and
override scenarios; CI job added to run E2E port-override tests.

* **Chore**
* Added compatibility shim to surface built artifacts and documented the
default dashboard port in the container build.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Signed-off-by: Prekshi Vyas <[email protected]>
Signed-off-by: Aaron Erickson <[email protected]>
Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: jnun <[email protected]>
Co-authored-by: Claude Opus 4.6 (1M context) <[email protected]>
Co-authored-by: Carlos Villela <[email protected]>
Co-authored-by: Aaron Erickson <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Signed-off-by: ColinM-sys <[email protected]>
@wscurran wscurran added area: install Install, setup, prerequisites, or uninstall flow area: onboarding Onboarding FSM, provider setup, sandbox launch, or first-run flow area: packaging Packages, images, registries, installers, or distribution platform: container Affects Docker, containerd, Podman, or images bug-fix PR fixes a bug or regression and removed area: packaging Packages, images, registries, installers, or distribution Getting Started labels Jun 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: install Install, setup, prerequisites, or uninstall flow area: onboarding Onboarding FSM, provider setup, sandbox launch, or first-run flow bug-fix PR fixes a bug or regression platform: container Affects Docker, containerd, Podman, or images

Projects

None yet

Development

Successfully merging this pull request may close these issues.

./install.sh assumes port 8080 isn't already in use

4 participants