DHL Node - Error: Socket Hang Up

I’m having a problem where every call to the Get Tracking Endpoint of the DHL Node results in an error: socket hang up. Is this an issue with the node or something else?

Information on your n8n setup

  • n8n version: 0.236.2
  • Database (default: SQLite): PostgresQL
  • n8n EXECUTIONS_PROCESS setting (default: own, main): own
  • Running n8n via (Docker, npm, n8n cloud, desktop app): Docker
  • Operating system: ubuntu server

Hi @ugly, I am very sorry you are having trouble.

This will most certainly be a network problem I am afraid. From testing this node just now on my end it appears to work fine using a setup similar to yours:

Are there any network components sitting between your n8n instance and the public internet that might interfere with the connection?

Or is there a chance your n8n instance is under a very high load/processing a large number of items at once, and thus preventing it from processing the response from DHL in a timely manner?

2 Likes

Hmm, nothing that I know of. Right now it’s just on a Hetzner cloud server. I am indeed calling the DHL Node with about 60 items in series but that hasn’t been an issue in the past. Calling it once with just the DHL node on a new workflow gets the same response.

Hetzner have been contacted and I will try DHL as well. Will post an update when I know more.

Edit: Trying it with the HTTP Request Node gives me the same error.

{
    "status": "rejected",
    "reason": {
        "message": "socket hang up",
        "name": "Error",
        "stack": "Error: socket hang up\n    at connResetException (node:internal/errors:705:14)\n    at TLSSocket.socketOnEnd (node:_http_client:518:23)\n    at TLSSocket.emit (node:events:525:35)\n    at TLSSocket.emit (node:domain:489:12)\n    at endReadableNT (node:internal/streams/readable:1358:12)\n    at processTicksAndRejections (node:internal/process/task_queues:83:21)",
        "config": {
            "url": "https://api-eu.dhl.com/track/shipments",
            "method": "get",
            "headers": {
                "Accept": "application/json,text/html,application/xhtml+xml,application/xml,text/*;q=0.9, image/*;q=0.8, */*;q=0.7",
                "dhl-api-key": "REDACTED",
                "User-Agent": "axios/0.21.4"
            },
            "params": {
                "trackingNumber": "REDACTED"
            },
            "transformRequest": [
                null
            ],
            "timeout": 3600000,
            "responseType": "stream",
            "xsrfCookieName": "XSRF-TOKEN",
            "xsrfHeaderName": "X-XSRF-TOKEN",
            "maxContentLength": null,
            "maxBodyLength": null,
            "transitional": {
                "silentJSONParsing": true,
                "forcedJSONParsing": true,
                "clarifyTimeoutError": false
            },
            "axios-retry": {
                "retryCount": 0,
                "lastRequestTime": 1697038475606
            }
        },
        "code": "ECONNRESET"
    }
}

Thanks for confirming @ugly and sorry for the trouble :frowning:

Just to rule out a number of possible problems, could you perform some additional checks here?

  1. Can you check the app status in DHL’s developer portal? It should be “approved” and the “Shipment Tracking - Unified” API should be “enabled”.

    Developer portal screenshot

  2. Can you try sending the request through curl on your n8n server, but outside of n8n? This will help with understanding whether the connection problem is limited to n8n or affecting your entire server. The command would be curl -v -H 'DHL-API-Key: ApiKeyHere' 'https://api-eu.dhl.com/track/shipments?trackingNumber=trackingNumberHere', the response should look like this:

    curl screenshot

  3. Can you spin up an n8n on your local machine and verify whether n8n’s DHL node runs outside of Hetzner for you? Assuming you have docker installed, docker run -it --rm --name n8n -p 5678:5678 n8nio/n8n:0.236.2 would start an n8n docker container (and remove it again once you press Ctrl+C in your terminal).

Thanks a lot!

1 Like

Sorry for my late response.

Hetzner gave me some strange answer about my IP Address being in Iran but doing an IP location check on it states that it’s in Nuremberg, Germany. As should be the case. So that doesn’t seem to be the issue.

Testing it locally with the same workflow as the server causes no problems and the DHL node has no issues with a socket hang up or time out of any kind.

Testing with curl on my server throws this error:

Looking at the OpenSSL error I’ve found there to be an issue with the default curl version not being able to handle certain OpenSSL 3.0.2 requests on Ubuntu 22.04. Any ideas if that could be the case before I manually update curl?

Hi @ugly, thanks so much for checking!

Testing with curl on my server throws this error:

I think this might not be a problem with curl in this case, I’ve just double-checked this by (successfully) using the example curl command on the default curl version on Ubuntu 22.04 running on a Hetzner server.

Instead it seems to me that DHL is simply blocking connection attempts from your server. This can sometimes happen if your server IP was abused by a previous owner.

So perhaps you want to raise a support request with DHL so they can whitelist your IP again?

1 Like

Thank you for the link! I’ve sent a ticket in and will update here afterwards.

1 Like

@ugly Did it work?

I have a similar problem. I installed retool on a hetzner server and dhl also seem to block me.
But DHL says they dont block IP Addresses and dont have any issues atm with their API. I also have the same curl error but python is installed on those severs so I tried calling httpbin and a nasa api both worked but when I try dhl api I get (‘Connection aborted.’, RemoteDisconnected(‘Remote end closed connection without response’)) for every endpoint.

Hi @robert2, welcome to the community!

Seeing you are also having this problem it appears this might indeed not be specific to a single IP but could point to a problem specific to the connection between the Hetzner data center and DHL. I don’t think it’s n8n specific seeing curl requests are failing for both of you.

Can you confirm if you’re also using the Nürnberg data centre operated by Hetzner?

FIXED!

Hetzner support gave me a cryptic reply which ended up helping. They mentioned that IP addresses going through Iran are being blocked. I checked the hops and nothing seemed to indicate it was going through Iran, especially to the DHL servers which are authenticated directly but oh well.

I created a new server in the Falkenhain location with a snapshot of the old server. This came with a new IP in the hopes that it would fix any IP range blocking issues on the DHL end.

Updated my DNS A record, waited for it to propagate (flushed the google cache here to try and speed things up and also checked with OpenDNS), and voila. That did the trick.

2 Likes

Woah, that’s crazy. I would have never guessed some routing through Iran being involved here. So glad you figured it out though, thanks so much for sharing!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.