forwardemail.net icon indicating copy to clipboard operation
forwardemail.net copied to clipboard

[fix] "The resolved IP address corresponds to a local interface" (self hosted)

Open S4r4h-O opened this issue 7 months ago • 8 comments

SMTP Envelope Date & Time 5/16/25, 7:38 AM MAIL FROM support@<my_domain.com> RCPT TO support@<my_domain.com>

Log Message Unable to deliver email to the IP address [<vps_ip>] resolved for the Mail Exchange (MX) server of "<my_domain.com>". The resolved IP address corresponds to a local interface.

Message Headers From "<my_domain.com>" support@<my_domain.com> To "<my_domain.com>" support@<my_domain.com> Subject <my_domain.com> – Email Deliverability Report Issue Message-ID <fcb714d1-11e8-9de0-1698-e39da2f24985@<my_domain.com>> Date Fri, 16 May 2025 10:38:08 +0000 MIME-Version 1.0 Content-Type multipart/alternative; boundary="--_NmP-11877084255b6410-Part_1"

# More detailed logs:

{ "bounce_category": "none", "domains": [ "68263252ff31feea389d7b3f" ], "is_empty_domains": false, "domains_checked_at": "2025-05-16T10:38:13.158Z", "err": { "name": "Error", "message": "Unable to deliver email to the IP address [<vps_ip>] resolved for the Mail Exchange (MX) server of "<my_domain.com>". The resolved IP address corresponds to a local interface.", "stack": "Error: Unable to deliver email to the IP address [<vps_ip>] resolved for the Mail Exchange (MX) server of "<my_domain.com>". The resolved IP address corresponds to a local interface.\n at filterAddress (/app/node_modules/.pnpm/[email protected]/node_modules/mx-connect/lib/resolve-ip.js:63:34)\n at Array.filter ()\n at /app/node_modules/.pnpm/[email protected]/node_modules/mx-connect/lib/resolve-ip.js:100:39\n at Array.forEach ()\n at /app/node_modules/.pnpm/[email protected]/node_modules/mx-connect/lib/resolve-ip.js:98:29\n at process.processTicksAndRejections (node:internal/process/task_queues:95:5)", "code": "InvalidIpAddress", "response": "DNS Error: Unable to deliver email to the IP address [<vps_ip>] resolved for the Mail Exchange (MX) server of "<my_domain.com>". The resolved IP address corresponds to a local interface.", "category": "dns", "isCodeBug": false }, "date": "2025-05-16T10:38:08.000Z", "subject": "<my_domain.com> – Email Deliverability Report Issue", "keywords": [ "b32812778b", "b11d461d8b", "66b6d75185" ], "text_message": "Unable to deliver email to the IP address [<vps_ip>] resolved for the Mail Exchange (MX) server of "<my_domain.com>". The resolved IP address corresponds to a local interface.", "message": "Unable to deliver email to the IP address [<vps_ip>] resolved for the Mail Exchange (MX) server of "<my_domain.com>". The resolved IP address corresponds to a local interface.", "meta": { "user": "682631ffff31feea389d7aba", "email": "68271591bf585ff4865c62f6", "domains": [ "68263252ff31feea389d7b3f" ], "session": { "envelope": { "mailFrom": { "address": "support@<my_domain.com>" }, "rcptTo": [ { "address": "support@<my_domain.com>" } ] }, "headers": { "From": ""<my_domain.com>" <support@<my_domain.com>", "To": ""<my_domain.com>" <support@<my_domain.com>", "Subject": "<my_domain.com> – Email Deliverability Report Issue", "Message-ID": "<fcb714d1-11e8-9de0-1698-e39da2f24985@<my_domain.com>", "Date": "Fri, 16 May 2025 10:38:08 +0000", "MIME-Version": "1.0", "Content-Type": "multipart/alternative; boundary="--_NmP-11877084255b6410-Part_1"" }, "originalFromAddress": "support@<my_domain.com>" }, "err": { "name": "Error", "message": "Unable to deliver email to the IP address [<vps_ip>] resolved for the Mail Exchange (MX) server of "<my_domain.com>". The resolved IP address corresponds to a local interface.", "stack": "Error: Unable to deliver email to the IP address [<vps_ip>] resolved for the Mail Exchange (MX) server of "<my_domain.com>". The resolved IP address corresponds to a local interface.\n at filterAddress (/app/node_modules/.pnpm/[email protected]/node_modules/mx-connect/lib/resolve-ip.js:63:34)\n at Array.filter ()\n at /app/node_modules/.pnpm/[email protected]/node_modules/mx-connect/lib/resolve-ip.js:100:39\n at Array.forEach ()\n at /app/node_modules/.pnpm/[email protected]/node_modules/mx-connect/lib/resolve-ip.js:98:29\n at process.processTicksAndRejections (node:internal/process/task_queues:95:5)", "code": "InvalidIpAddress", "response": "DNS Error: Unable to deliver email to the IP address [<vps_ip>] resolved for the Mail Exchange (MX) server of "<my_domain.com>". The resolved IP address corresponds to a local interface.", "category": "dns" }, "level": "error", "app": { "name": "forward-email", "version": "1.0.3", "node": "v20.19.1", "environment": "production", "hostname": "smtp.<my_domain.com>", "ip": "<vps_ip>", "pid": 1, "cluster": { "isPrimary": true, "isWorker": false, "schedulingPolicy": 2 }, "os": { "arch": "x64", "cpus": [ { "model": "AMD EPYC 9354P 32-Core Processor", "speed": 0, "times": { "user": 819920, "nice": 48080, "sys": 454250, "idle": 8924150, "irq": 0 } }, { "model": "AMD EPYC 9354P 32-Core Processor", "speed": 0, "times": { "user": 809820, "nice": 44380, "sys": 425010, "idle": 9088920, "irq": 0 } } ], "endianness": "LE", "freemem": 6578036736, "priority": 0, "homedir": "/root", "hostname": "smtp.<my_domain.com>", "loadavg": [ 0.77, 0.41, 0.6 ], "network_interfaces": { "lo": [ { "address": "127.0.0.1", "netmask": "255.0.0.0", "family": "IPv4", "mac": "00:00:00:00:00:00", "internal": true, "cidr": "127.0.0.1/8" }, { "address": "::1", "netmask": "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff", "family": "IPv6", "mac": "00:00:00:00:00:00", "internal": true, "cidr": "::1/128", "scopeid": 0 } ], "eth0": [ { "address": "<vps_ip>", "netmask": "255.255.255.0", "family": "IPv4", "mac": "fc:e8:d4:b1:88:d6", "internal": false, "cidr": "<vps_ip>/24" }, { "address": "2a02:4780:14:4612::1", "netmask": "ffff:ffff:ffff::", "family": "IPv6", "mac": "fc:e8:d4:b1:88:d6", "internal": false, "cidr": "2a02:4780:14:4612::1/48", "scopeid": 0 }, { "address": "fe80::fee8:d4ff:feb1:88d6", "netmask": "ffff:ffff:ffff:ffff::", "family": "IPv6", "mac": "fc:e8:d4:b1:88:d6", "internal": false, "cidr": "fe80::fee8:d4ff:feb1:88d6/64", "scopeid": 2 } ] }, "platform": "linux", "release": "5.15.0-140-generic", "tmpdir": "/tmp", "totalmem": 8322453504, "type": "Linux", "uptime": 11078.15, "user": { "uid": 0, "gid": 0, "username": "root", "homedir": "/root", "shell": "/bin/bash" }, "version": "#150-Ubuntu SMP Sat Apr 12 06:00:09 UTC 2025" }, "worker_threads": { "isMainThread": false, "resourceLimits": { "maxYoungGenerationSizeMb": 48, "maxOldGenerationSizeMb": 2048, "codeRangeSizeMb": 0, "stackSizeMb": 4 }, "threadId": 1, "workerData": { "job": { "name": "send-emails", "interval": 30000, "timeout": 0, "path": "/app/jobs/send-emails.js", "timezone": "local" } } } } }, "created_at": "2025-05-16T10:38:12.963Z", "is_restricted": true, "id": "68271594183cf1756b69cd90", "object": "log", "updated_at": "2025-05-16T10:38:12.963Z" }

S4r4h-O avatar May 16 '25 12:05 S4r4h-O

From the mx container, if I dig the DOMAIN or hostname then I should get back the VPS IP. Are you getting a response of 127.0.0.1 / loopback address? You may need to add a hostname or label configuration on the VPS provider to ensure that the hostname binds and resolves to the VPS IP even from within the host and container (using dockers network mode host)

shaunwarman avatar Sep 04 '25 01:09 shaunwarman

To fix this, you need to set blockLocalAddresses to false for self-hosting most likely

Line 234 in a9eef13 blockLocalAddresses: env.NODE_ENV !== 'test',

I changed this on my self-hosted within the mx container, file /app/helpers/get-transporter.js to: blockLocalAddresses: false,

But I still get the error, even after restarting.

Also my Domain/Hostname resolves correctly within the mx container to the ip of the vps.

Is it not possible to send e-mails from one alias / domain to another when it is on the same self-hosted server? Always this error. Any idea / fix?

AlexP38 avatar Nov 21 '25 22:11 AlexP38

cc @shaunwarman not sure if you know how to fix this

titanism avatar Nov 21 '25 22:11 titanism

@AlexP38 You can try setting (or changing) AXE_SILENT=false AXE_SHOW_META=true AXE_SHOW_STACK=true in your .env file on your server for this project's git repo, then reload, and then watch the logs for the full stack trace when this happens - then send it here so I can look closer (this might be happening elsewhere)

Also @AlexP38 you can also join our Matrix chat for real-time chat with myself and @shaunwarman so we can help further

To join, go to https://matrix.to/#/#forwardemail:matrix.org

titanism avatar Nov 21 '25 22:11 titanism

This is the log I get: { "bounce_category": "none", "domains": [ "691f8defc481c837f993cf05", "69165b1c9d9529018411c354" ], "is_empty_domains": false, "domains_checked_at": "2025-11-21T23:01:06.791Z", "err": { "name": "Error", "message": "Unable to deliver email to the IP address [ip.address] resolved for the Mail Exchange (MX) server of "domain2.xyz". The resolved IP address corresponds to a local interface.", "stack": "Error: Unable to deliver email to the IP address [ip.address] resolved for the Mail Exchange (MX) server of "domain2.xyz". The resolved IP address corresponds to a local interface.\n at filterAddress (/app/node_modules/.pnpm/[email protected]/node_modules/mx-connect/lib/resolve-ip.js:63:34)\n at Array.filter ()\n at /app/node_modules/.pnpm/[email protected]/node_modules/mx-connect/lib/resolve-ip.js:100:39\n at Array.forEach ()\n at /app/node_modules/.pnpm/[email protected]/node_modules/mx-connect/lib/resolve-ip.js:98:29\n at process.processTicksAndRejections (node:internal/process/task_queues:95:5)", "code": "InvalidIpAddress", "response": "DNS Error: Unable to deliver email to the IP address [ip.address] resolved for the Mail Exchange (MX) server of "domain2.xyz". The resolved IP address corresponds to a local interface.", "category": "dns", "isCodeBug": false }, "date": "2025-11-21T23:00:34.000Z", "subject": "Text domain1.xyz an domain2.xyz", "keywords": [ "129d529665", "0182c953ba", "5a8e930a18", "38eb6f6fb6", "309a2e7059" ], "text_message": "Unable to deliver email to the IP address [ip.address] resolved for the Mail Exchange (MX) server of "domain2.xyz". The resolved IP address corresponds to a local interface.", "message": "Unable to deliver email to the IP address [ip.address] resolved for the Mail Exchange (MX) server of "domain2.xyz". The resolved IP address corresponds to a local interface.", "meta": { "user": "691624e59d9529018411b71a", "email": "6920ef1443bb951d114fe722", "domains": [ "691f8defc481c837f993cf05" ], "session": { "envelope": { "mailFrom": { "address": "[email protected]" }, "rcptTo": [ { "address": "[email protected]" } ] }, "headers": { "Message-ID": "[email protected]", "Date": "Sat, 22 Nov 2025 00:00:34 +0100", "MIME-Version": "1.0", "User-Agent": "Mozilla Thunderbird", "Content-Language": "en-US", "To": "[email protected]", "From": "name [email protected]", "Subject": "Text domain1.xyz an domain2.xyz", "Content-Type": "text/plain; charset=UTF-8; format=flowed", "Content-Transfer-Encoding": "7bit" }, "originalFromAddress": "[email protected]" }, "err": { "name": "Error", "message": "Unable to deliver email to the IP address [ip.address] resolved for the Mail Exchange (MX) server of "domain2.xyz". The resolved IP address corresponds to a local interface.", "stack": "Error: Unable to deliver email to the IP address [ip.address] resolved for the Mail Exchange (MX) server of "domain2.xyz". The resolved IP address corresponds to a local interface.\n at filterAddress (/app/node_modules/.pnpm/[email protected]/node_modules/mx-connect/lib/resolve-ip.js:63:34)\n at Array.filter ()\n at /app/node_modules/.pnpm/[email protected]/node_modules/mx-connect/lib/resolve-ip.js:100:39\n at Array.forEach ()\n at /app/node_modules/.pnpm/[email protected]/node_modules/mx-connect/lib/resolve-ip.js:98:29\n at process.processTicksAndRejections (node:internal/process/task_queues:95:5)", "code": "InvalidIpAddress", "response": "DNS Error: Unable to deliver email to the IP address [ip.address] resolved for the Mail Exchange (MX) server of "domain2.xyz". The resolved IP address corresponds to a local interface.", "category": "dns" }, "level": "error", "app": { "name": "forward-email", "version": "1.4.3", "node": "v20.19.5", "environment": "production", "hostname": "smtp.server-domain.xyz", "ip": "ip.address", "pid": 1, "cluster": { "isPrimary": true, "isWorker": false, "schedulingPolicy": 2 }, "os": { "arch": "x64", "cpus": [ { "model": "Intel Core Processor (Haswell, no TSX)", "speed": 0, "times": { "user": 4660, "nice": 0, "sys": 1900, "idle": 6200, "irq": 0 } }, { "model": "Intel Core Processor (Haswell, no TSX)", "speed": 0, "times": { "user": 4020, "nice": 0, "sys": 2110, "idle": 6630, "irq": 0 } }, { "model": "Intel Core Processor (Haswell, no TSX)", "speed": 0, "times": { "user": 4760, "nice": 0, "sys": 1850, "idle": 6200, "irq": 0 } }, { "model": "Intel Core Processor (Haswell, no TSX)", "speed": 0, "times": { "user": 4060, "nice": 0, "sys": 2100, "idle": 6430, "irq": 0 } }, { "model": "Intel Core Processor (Haswell, no TSX)", "speed": 0, "times": { "user": 4330, "nice": 0, "sys": 2090, "idle": 6400, "irq": 0 } }, { "model": "Intel Core Processor (Haswell, no TSX)", "speed": 0, "times": { "user": 4100, "nice": 0, "sys": 1910, "idle": 6850, "irq": 0 } } ], "endianness": "LE", "freemem": 10231074816, "priority": 0, "homedir": "/root", "hostname": "smtp.server-domain.xyz", "loadavg": [ 1.44, 0.3, 0.1 ], "network_interfaces": { "lo": [ { "address": "127.0.0.1", "netmask": "255.0.0.0", "family": "IPv4", "mac": "00:00:00:00:00:00", "internal": true, "cidr": "127.0.0.1/8" }, { "address": "::1", "netmask": "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff", "family": "IPv6", "mac": "00:00:00:00:00:00", "internal": true, "cidr": "::1/128", "scopeid": 0 } ], "ens3": [ { "address": "ip.address", "netmask": "255.255.255.255", "family": "IPv4", "mac": "mac.address", "internal": false, "cidr": "ip.address/32" }, { "address": "ip.address.2", "netmask": "255.255.255.255", "family": "IPv4", "mac": "mac.address", "internal": false, "cidr": "ip.address.2/32" }, { "address": "ip.v6.address", "netmask": "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff", "family": "IPv6", "mac": "mac.address", "internal": false, "cidr": "ip.v6.address/128", "scopeid": 0 }, { "address": "other.ip.v6.address", "netmask": "ffff:ffff:ffff:ffff::", "family": "IPv6", "mac": "mac.address", "internal": false, "cidr": "other.ip.v6.address/64", "scopeid": 2 } ] }, "platform": "linux", "release": "6.8.0-87-generic", "tmpdir": "/tmp", "totalmem": 12243714048, "type": "Linux", "uptime": 13.26, "user": { "uid": 0, "gid": 0, "username": "root", "homedir": "/root", "shell": "/bin/bash" }, "version": "#88-Ubuntu SMP PREEMPT_DYNAMIC Sat Oct 11 09:28:41 UTC 2025" }, "worker_threads": { "isMainThread": false, "resourceLimits": { "maxYoungGenerationSizeMb": 48, "maxOldGenerationSizeMb": 2048, "codeRangeSizeMb": 0, "stackSizeMb": 4 }, "threadId": 1, "workerData": { "job": { "name": "send-emails", "interval": 30000, "timeout": 0, "path": "/app/jobs/send-emails.js", "timezone": "local" } } } } }, "created_at": "2025-11-21T23:00:40.800Z", "is_restricted": true, "id": "6920ef187fd983b665312740", "object": "log", "updated_at": "2025-11-21T23:00:40.800Z" }

AlexP38 avatar Nov 21 '25 23:11 AlexP38

It doesn't appear like your variable is set to false properly, or not rebooted perhaps?

You could edit the mx-connect codebase / pnpm file in your log output and do a console.log('dnsOptions', dnsOptions) to see what it's being passed, and also a console.log('stack', new Error('stack').stack); to get full stack trace.

cc @AlexP38

titanism avatar Nov 21 '25 23:11 titanism

I finally found my error: change this in the file /app/helpers/get-transporter.js within the smtp_bree container, not the mx container! blockLocalAddresses: false, Then it is working.

But: What about if the autoupdater makes an update? Is it possible to make this a .env variable to keep it?

AlexP38 avatar Nov 22 '25 15:11 AlexP38