Skip to content

bug(dashmate): port check reports INVALID_IP on a host with several public IPs #5976

Done

Description

@hobby-eng

Expected Behavior

A node can be bound to a public IPv4 address that is not the host's primary address (externalIp, core.p2p.host, platform.gateway.listeners.dapiAndDrive.host and platform.drive.tenderdash.p2p.host all set to that address). This happens when several evonodes share one server, each with its own IP, and also when a single node uses an additional IP because the primary one is taken by something else. In every such case dashmate status core, dashmate status platform and dashmate doctor should report OPEN when the port is reachable on the node's externalIp.

Current Behavior

The check is correct only when externalIp is the address the host uses for outgoing connections. A node on any other local address gets INVALID_IP (shown as P2P port: INVALID_IP in status core), even though its ports are open and the node works. When the request itself fails, the field shows ERROR.

providers.mnowatch.checkPortStatus(port, ip) sends GET https://mnowatch.org/<port>/?validateIp=<ip>. mnowatch.org answers INVALID_IP when the address the request comes from differs from validateIp. The request does not set a source address, so the kernel uses the source address of the default route, usually the host's primary IP, whatever the node's externalIp is.

The same function is used by:

  • src/status/scopes/core.js: core.p2p.port
  • src/status/scopes/platform.js: the gateway port and the Tenderdash P2P port
  • src/listr/tasks/doctor/collectSamplesTaskFactory.js: port 80, the Core P2P port, the gateway port and the Tenderdash P2P port

Possible Solution

I suggest sending the request from externalIp when that address is assigned to the local machine. Behind NAT, on a cloud VM with a private address, or inside the helper container the address is not local; binding there would fail with EADDRNOTAVAIL, so the request should leave as it does today.

--- a/packages/dashmate/src/status/providers.js
+++ b/packages/dashmate/src/status/providers.js
@@ -1,6 +1,14 @@
 import https from 'https';
+import os from 'os';
 import semver from 'semver';
 
+// mnowatch.org compares validateIp with the address the request comes from,
+// so on a host with several public IPs the request has to leave from the
+// node's own IP. Behind NAT that IP is not local and nothing changes.
+const isLocalAddress = (ip) => Object.values(os.networkInterfaces())
+  .flat()
+  .some((iface) => iface && iface.address === ip);
+
 const MAX_REQUEST_TIMEOUT = 5000;
 const MAX_RESPONSE_SIZE = 1 * 1024 * 1024; // 1 MB
 
@@ -284,6 +292,10 @@ export default {
         family: 4, // Force IPv4
       };
 
+      if (ip && isLocalAddress(ip)) {
+        options.localAddress = ip;
+      }
+
       return new Promise((resolve, reject) => {
         const req = https.request(options, (res) => {
           let data = '';

The diff is against v5.1-dev. I checked these request options with the Node runtime bundled with dashmate 5.0.3 (v24.14.1): with localAddress set, mnowatch.org answers OPEN for a node on an additional IP, and for an address that is not on the host the binding is skipped and the request behaves as before.

Steps to Reproduce (for bugs)

On a host where 203.0.113.10 is the primary address and 198.51.100.20 is an additional address with a node listening on 19999:

curl -4 -s "https://mnowatch.org/19999/?validateIp=198.51.100.20"
# INVALID_IP

curl -4 -s --interface 198.51.100.20 "https://mnowatch.org/19999/?validateIp=198.51.100.20"
# OPEN

Then dashmate status core --config <node on 198.51.100.20> shows P2P port: INVALID_IP.

Context

I ran into this with two nodes on one server, each on its own IP. Nodes on additional IPs are common: several evonodes on one dedicated server, each with its own address from the hosting provider, or one node next to other services that keep the primary address. In both cases the wrong status makes a working node look unreachable, and dashmate doctor reports the same wrong results.

Related: #2100, where the same request had to be forced to IPv4.

My Environment

  • dashmate 5.0.3 (linux-x64, bundled Node v24.14.1); the code is unchanged on v5.1-dev
  • Ubuntu 26.04.1, Docker 29.9.3
  • I run two testnet evonodes on one host, each with its own public IPv4

Activity

  1. hobby-eng commented on Dec 2, 2026

    @hobby-eng
    ContributorAuthor

    Fixed by #6407, merged into v5.1-dev in 956ee2f. It will ship in the next 5.1.x release. Thanks for the review!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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