Skip to content

An open source, self-hosted, real-time port monitoring and discovery tool.

fix(health): use docker host gateway fallback for 0.0.0.0 ports

Mostafa-Wahied7e293ec687c7
diff --git a/CHANGELOG.md b/CHANGELOG.md
index aa0de2f..39eb1c1 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,6 +4,14 @@ All notable changes to portracker will be documented in this file.
## [Unreleased]
+## [1.3.9] - 2026-05-05
+
+### Fixed
+
+<!-- whatsnew:title=Service status fix on default Docker bridge -->
+<!-- whatsnew:description=Probes now use the Docker host gateway when a port is bound to 0.0.0.0, so status no longer flips to yellow/red without HOST_OVERRIDE. -->
+- **[Probe Host Resolution]**: Service status probes fall back to the Docker host gateway for `0.0.0.0`/`::` ports instead of `127.0.0.1`, fixing false yellow/red statuses on default-bridge installs without `HOST_OVERRIDE`.
+
## [1.3.8] - 2026-05-04
### Dashboard & UX
diff --git a/backend/index.js b/backend/index.js
index 81068cd..fe85ee8 100644
--- a/backend/index.js
+++ b/backend/index.js
@@ -13,7 +13,6 @@ const { createCollector, detectCollector } = require('./collectors');
const net = require('net');
const db = require('./db');
const https = require("https");
-const os = require("os");
const { requireAuth, requireAuthOrApiKey, checkAuthEnabled, isAuthEnabled } = require('./middleware/auth');
const authRoutes = require('./routes/auth');
const settingsRoutes = require('./routes/settings');
@@ -21,6 +20,7 @@ const autoxposeRoutes = require('./routes/autoxpose');
const { registerServerRoutes } = require('./routes/servers');
const recoveryManager = require('./lib/recovery-manager');
const { enrichComposeLabelsOnPorts: enrichComposeLabelsOnPortsImpl } = require('./lib/docker/compose-attribution');
+const { getDockerHostIP } = require('./lib/docker-host');
const logger = new Logger("Server", { debug: process.env.DEBUG === 'true' });
const BASE_DEBUG = process.env.DEBUG === 'true';
@@ -119,85 +119,6 @@ function detectServiceType(port, owner) {
return { name: 'Service', type: 'service', description: 'Application service' };
}
-function getDockerHostIP() {
- const platform = os.platform();
-
- if (platform === 'darwin' || platform === 'win32') {
- return "host.docker.internal";
- }
-
- if (isDockerDesktopEnvironment()) {
- return "host.docker.internal";
- }
-
- try {
- if (fs.existsSync('/proc/net/route')) {
- const routes = fs.readFileSync('/proc/net/route', 'utf8');
- const lines = routes.split('\n');
- for (const line of lines) {
- const fields = line.split('\t');
- if (fields[1] === '00000000' && fields[7] === '00000000') {
- const gatewayHex = fields[2];
- const gateway = [
- parseInt(gatewayHex.substr(6, 2), 16),
- parseInt(gatewayHex.substr(4, 2), 16),
- parseInt(gatewayHex.substr(2, 2), 16),
- parseInt(gatewayHex.substr(0, 2), 16)
- ].join('.');
- return gateway;
- }
- }
- }
- } catch (err) {
- logger.warn('Failed to detect Docker host IP from /proc/net/route:', err.message);
- }
-
- return "172.17.0.1";
-}
-
-function isDockerDesktopEnvironment() {
- try {
- if (process.env.DOCKER_DESKTOP === 'true') {
- return true;
- }
-
- if (fs.existsSync('/proc/version')) {
- const version = fs.readFileSync('/proc/version', 'utf8');
- if (version.includes('linuxkit') || version.includes('docker-desktop')) {
- return true;
- }
- }
-
- if (fs.existsSync('/proc/net/route')) {
- const routes = fs.readFileSync('/proc/net/route', 'utf8');
- const gatewayLines = routes.split('\n').filter(line => {
- const fields = line.split('\t');
- return fields[1] === '00000000';
- });
-
- for (const line of gatewayLines) {
- const fields = line.split('\t');
- const gatewayHex = fields[2];
- const gateway = [
- parseInt(gatewayHex.substr(6, 2), 16),
- parseInt(gatewayHex.substr(4, 2), 16),
- parseInt(gatewayHex.substr(2, 2), 16),
- parseInt(gatewayHex.substr(0, 2), 16)
- ].join('.');
-
- if (gateway.startsWith('192.168.65.') || gateway.startsWith('172.19.') || gateway.startsWith('172.20.')) {
- return true;
- }
- }
- }
-
- return false;
- } catch (err) {
- logger.debug("Error checking Docker Desktop environment:", { error: err.message });
- return false;
- }
-}
-
async function testProtocol(scheme, host_ip, port, path = "/", isDebugEnabled = false) {
const controller = new AbortController();
const timeout = setTimeout(() => controller.abort(), PING_TIMEOUT);
diff --git a/backend/lib/docker-host.js b/backend/lib/docker-host.js
new file mode 100644
index 0000000..8ccd791
--- /dev/null
+++ b/backend/lib/docker-host.js
@@ -0,0 +1,87 @@
+'use strict';
+
+const fs = require('fs');
+const os = require('os');
+
+function isDockerDesktopEnvironment() {
+ try {
+ if (process.env.DOCKER_DESKTOP === 'true') {
+ return true;
+ }
+
+ if (fs.existsSync('/proc/version')) {
+ const version = fs.readFileSync('/proc/version', 'utf8');
+ if (version.includes('linuxkit') || version.includes('docker-desktop')) {
+ return true;
+ }
+ }
+
+ if (fs.existsSync('/proc/net/route')) {
+ const routes = fs.readFileSync('/proc/net/route', 'utf8');
+ const gatewayLines = routes.split('\n').filter(line => {
+ const fields = line.split('\t');
+ return fields[1] === '00000000';
+ });
+
+ for (const line of gatewayLines) {
+ const fields = line.split('\t');
+ const gatewayHex = fields[2];
+ const gateway = [
+ parseInt(gatewayHex.substr(6, 2), 16),
+ parseInt(gatewayHex.substr(4, 2), 16),
+ parseInt(gatewayHex.substr(2, 2), 16),
+ parseInt(gatewayHex.substr(0, 2), 16)
+ ].join('.');
+
+ if (gateway.startsWith('192.168.65.') || gateway.startsWith('172.19.') || gateway.startsWith('172.20.')) {
+ return true;
+ }
+ }
+ }
+
+ return false;
+ } catch (_err) {
+ return false;
+ }
+}
+
+function getDockerHostIP() {
+ const platform = os.platform();
+
+ if (platform === 'darwin' || platform === 'win32') {
+ return 'host.docker.internal';
+ }
+
+ if (isDockerDesktopEnvironment()) {
+ return 'host.docker.internal';
+ }
+
+ try {
+ if (fs.existsSync('/proc/net/route')) {
+ const routes = fs.readFileSync('/proc/net/route', 'utf8');
+ const lines = routes.split('\n');
+ for (const line of lines) {
+ const fields = line.split('\t');
+ if (fields[1] === '00000000' && fields[7] === '00000000') {
+ const gatewayHex = fields[2];
+ const gateway = [
+ parseInt(gatewayHex.substr(6, 2), 16),
+ parseInt(gatewayHex.substr(4, 2), 16),
+ parseInt(gatewayHex.substr(2, 2), 16),
+ parseInt(gatewayHex.substr(0, 2), 16)
+ ].join('.');
+ return gateway;
+ }
+ }
+ }
+ } catch (_err) {
+ void _err;
+ }
+
+ return '172.17.0.1';
+}
+
+module.exports = {
+ getDockerHostIP,
+ isDockerDesktopEnvironment,
+};
diff --git a/backend/lib/health/service-health.js b/backend/lib/health/service-health.js
index 8addb3f..14c3be4 100644
--- a/backend/lib/health/service-health.js
+++ b/backend/lib/health/service-health.js
@@ -12,6 +12,19 @@ const {
DEFAULT_TIMEOUT_MS,
} = require('./probes');
const { aggregate } = require('./aggregate');
+const { getDockerHostIP } = require('../docker-host');
+
+let cachedDockerHostIp;
+function dockerHostIpFallback() {
+ if (cachedDockerHostIp === undefined) {
+ try {
+ cachedDockerHostIp = getDockerHostIP() || '';
+ } catch (_e) {
+ cachedDockerHostIp = '';
+ }
+ }
+ return cachedDockerHostIp;
+}
function safeLower(v) {
return typeof v === 'string' ? v.toLowerCase() : '';
@@ -21,7 +34,7 @@ function resolveProbeHost(hostIp) {
const h = safeLower(hostIp);
const override = (process.env.HOST_OVERRIDE || '').trim();
if (h === '' || h === '0.0.0.0' || h === '::' || h === '[::]') {
- return override || '127.0.0.1';
+ return override || dockerHostIpFallback() || '127.0.0.1';
}
if (h === '::1') return '::1';
return hostIp;
diff --git a/backend/package.json b/backend/package.json
index fbc5ec8..73c4d0f 100644
--- a/backend/package.json
+++ b/backend/package.json
@@ -1,6 +1,6 @@
{
"name": "backend",
- "version": "1.3.8",
+ "version": "1.3.9",
"description": "",
"main": "index.js",
"scripts": {
diff --git a/frontend/package.json b/frontend/package.json
index 2f7560d..343fd47 100644
--- a/frontend/package.json
+++ b/frontend/package.json
@@ -1,7 +1,7 @@
{
"name": "frontend",
"private": true,
- "version": "1.3.8",
+ "version": "1.3.9",
"type": "module",
"scripts": {
"dev": "vite",
diff --git a/package.json b/package.json
index 2e407bd..03cbeb2 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "portracker",
- "version": "1.3.8",
+ "version": "1.3.9",
"description": "A multi-platform port-tracking dashboard",
"main": "backend/index.js",
"scripts": {