HTTPS Request returns 500 when connected to PostgreSQL query

Describe the issue/error/question

HTTPS query runs well when connected to other nodes than PostgreSQL or on its own. Connected to a PostgreSQL query it shows an error 500 (executing the whole flow or the node on its own)

What is the error message (if any)?

{
“status”: “rejected”,
“reason”: {
“message”: “Request failed with status code 500”,
“name”: “Error”,
“stack”: “Error: Request failed with status code 500 at createError (ProfileFolder\AppData\Local\Programs\n8n\resources\app\node_modules\axios\lib\core\createError.js:16:15) at settle (ProfileFolder\AppData\Local\Programs\n8n\resources\app\node_modules\axios\lib\core\settle.js:17:12) at IncomingMessage.handleStreamEnd (ProfileFolder\AppData\Local\Programs\n8n\resources\app\node_modules\axios\lib\adapters\http.js:269:11) at IncomingMessage.emit (node:events:406:35) at IncomingMessage.emit (node:domain:470:12) at endReadableNT (node:internal/streams/readable:1331:12) at processTicksAndRejections (node:internal/process/task_queues:83:21)”
}
}

Please share the workflow

{
  "nodes": [
    {
      "parameters": {
        "operation": "executeQuery",
        "query": "select * from restricted.businesspartners where type ='client'",
        "additionalFields": {}
      },
      "name": "Get all Clients",
      "type": "n8n-nodes-base.postgres",
      "typeVersion": 1,
      "position": [
        440,
        310
      ],
      "credentials": {
        "postgres": {
          "id": "1",
          "name": "Postgres account"
        }
      }
    },
    {
      "parameters": {
        "authentication": "headerAuth",
        "requestMethod": "POST",
        "url": "https://invoicing.co/api/v1/clients",
        "options": {},
        "bodyParametersUi": {
          "parameter": [
            {
              "name": "name",
              "value": "123"
            }
          ]
        }
      },
      "name": "Create Client",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [
        610,
        310
      ],
      "retryOnFail": true,
      "credentials": {
        "httpHeaderAuth": {
          "id": "6",
          "name": "InvoiceNinja TEST"
        }
      }
    }
  ],
  "connections": {
    "Get all Clients": {
      "main": [
        [
          {
            "node": "Create Client",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

Information on your n8n setup

  • n8n version: 1.0
  • Running n8n via [Docker, npm, n8n.cloud, desktop app]: Desktop App

Hi @SteffenN, the 500 error is an error thrown by the system you are sending data to (invoicing.co in this case), not by n8n. The HTTP Request node itself would run find after the PostgreSQL node:

Example Workflow
{
  "nodes": [
    {
      "parameters": {},
      "name": "Start",
      "type": "n8n-nodes-base.start",
      "typeVersion": 1,
      "position": [
        240,
        300
      ]
    },
    {
      "parameters": {
        "operation": "executeQuery",
        "query": "select 'dummy';",
        "additionalFields": {}
      },
      "name": "Get all Clients",
      "type": "n8n-nodes-base.postgres",
      "typeVersion": 1,
      "position": [
        460,
        300
      ],
      "credentials": {
        "postgres": {
          "id": "39",
          "name": "ElephantSQL"
        }
      }
    },
    {
      "parameters": {
        "requestMethod": "POST",
        "url": "https://httpbin.org/anything",
        "options": {},
        "bodyParametersUi": {
          "parameter": [
            {
              "name": "name",
              "value": "123"
            }
          ]
        }
      },
      "name": "Create Client",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [
        680,
        300
      ],
      "retryOnFail": true
    }
  ],
  "connections": {
    "Start": {
      "main": [
        [
          {
            "node": "Get all Clients",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get all Clients": {
      "main": [
        [
          {
            "node": "Create Client",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

So I’m wondering if there’s more to it than what’s shown in your example workflow. Are you using the client IDs from your SQL query in your HTTP Request? If so, which expression are you using?

Hi @MutedJam ,

I understand the meaning of error 500, but when not connected to any node, it will not show an error and will run as expected:

When connecting the HTTPS node to any PostgreSQL node, without using any data from it, the error will occur:

Cheers,
Steffen

I’m really sorry @SteffenN, I could not reproduce the problem using the example workflow you have provided for two reasons:

  1. I don’t know which data is returned by your PostgreSQL node.
  2. I do not have access to the authentication data from your HTTP Request node.

As you can see from my example workflow, connecting the PostgreSQL node to an HTTP Request node would not automatically cause a problem. This strongly suggests the problem you are seeing might be caused by the data you are working with.

A potential cause could be that your PostgreSQL node is returning a large number of items. The HTTP Request node would then make requests for every single item it receives in very quick succession. A large number of items might be too much for the receiving server to handle, eventually leading to the 500 error. You could verify this by having your PostgreSQL node return only a single item (for example by running a query like select 123 as test;).

Where the PostgreSQL node wouldn’t return any data at all, the HTTP request node would not run since there is no item for which it could run (unless there are additional settings not part of the example you have shared):

But ultimately, only the operator of the receiving server can confirm why exactly a specific error is being returned at a given time.

Edit: Your screenshot suggests you might be working with an older version of n8n - the desktop app got an update recently, so you might want to fetch it from https://n8n.io/. You can just install the new version over the old one. It wouldn’t change how HTTP requests are handled, but can increase visibility into the number of items passed on by each node as seen on my screenshot.