HTTP Requests to RapidAPI returns Error

Describe the problem/error/question

I’m having an issue with RapidAPI and the Http Request module. wget commands work to access the API on my personal computer, on the hosting docker computer, inside of the docker container. When I use the HTTP Request module It fails.

What is the error message (if any)?

Output details from N8N:

{
  "errorMessage": "Bad gateway - the service failed to handle your request [item 5]",
  "errorDescription": "The API is unreachable, please contact the API provider",
  "errorDetails": {
    "rawErrorMessage": [
      "502 - \"{\\\"messages\\\":\\\"The API is unreachable, please contact the API provider\\\", \\\"info\\\": \\\"Your Client (working) ---> Gateway (working) ---> API (not working)\\\"}\""
    ],
    "httpCode": "502"
  },
  "n8nDetails": {
    "nodeName": "HTTP Request2",
    "nodeType": "n8n-nodes-base.httpRequest",
    "nodeVersion": 4.2,
    "itemIndex": 5,
    "time": "9/2/2024, 3:43:43 PM",
    "n8nVersion": "1.56.2 (Self Hosted)",
    "binaryDataMode": "default",
    "stackTrace": [
      "NodeApiError: Bad gateway - the service failed to handle your request",
      "    at Object.execute (/usr/local/lib/node_modules/n8n/node_modules/n8n-nodes-base/dist/nodes/HttpRequest/V3/HttpRequestV3.node.js:1650:33)",
      "    at processTicksAndRejections (node:internal/process/task_queues:95:5)",
      "    at Workflow.runNode (/usr/local/lib/node_modules/n8n/node_modules/n8n-workflow/dist/Workflow.js:728:19)",
      "    at /usr/local/lib/node_modules/n8n/node_modules/n8n-core/dist/WorkflowExecute.js:673:51",
      "    at /usr/local/lib/node_modules/n8n/node_modules/n8n-core/dist/WorkflowExecute.js:1104:20"
    ]
  }
}
{
    "headers": {
        "x-rapidapi-host": "google-news22.p.rapidapi.com",
        "x-rapidapi-key": "xxxxxx",
        "accept": "application/json,text/html,application/xhtml+xml,application/xml,text/*;q=0.9, image/*;q=0.8, */*;q=0.7"
    },
    "method": "GET",
    "uri": "https://google-news22.p.rapidapi.com/v1/search",
    "gzip": true,
    "rejectUnauthorized": true,
    "followRedirect": true,
    "resolveWithFullResponse": true,
    "followAllRedirects": true,
    "timeout": 300000,
    "qs": {
        "q": "Wealth",
        "country": "us",
        "language": "en"
    },
    "encoding": null,
    "json": false,
    "useStream": true
}

Please share your workflow

(Select the nodes on your canvas and use the keyboard shortcuts CMD+C/CTRL+C and CMD+V/CTRL+V to copy and paste the workflow.)

Information on your n8n setup

  • n8n version: 1.56.2
  • Database (default: SQLite): Postgres
  • n8n EXECUTIONS_PROCESS setting (default: own, main): default
  • Running n8n via (Docker, npm, n8n cloud, desktop app): Docker
  • Operating system: UnRaid

I had to roll back to 1.55.3 to get it to work.

1 Like

Hi @rainmanjam

the error code 502 usually indicates it’s a server error. You could try again with a recent version and try setting the node setting’s to Retry on Fail with some wait time between the retries.

Would be good to find out if it’s really n8n or the API itself.

@ria Thanks. The 502 error message line was more detailed if you scrolled more to the right. It explained that everything worked until it reached the API. It’s just an odd response from a node that’s been reliable.