Help connecting OpenAI credential

Hey guys, I can’t connect my OpenAI credential on my n8n platform, but before it was working well. Why ? I created a new account yesterday and the problem happened like this.

I already made those 3 solutions :

  • Create a new secret key
  • Add more $ on my OpenAI wallet
  • Turn on all permissions on OpenAI Platform

Here is the problem

Information on your n8n setup

  • n8n version: 2.19.2
  • Running n8n via (Docker, npm, n8n cloud, desktop app): VPS Hostinger
  • Operating system: Ubuntu 24.04

The error config.headers.setContentType is not a function is a known bug that appeared in some n8n versions around 2.18-2.19. It’s not related to your API key or OpenAI account - it’s a compatibility issue with how the credential test request is built internally.

A few things you can try:

  1. Update to the latest n8n version (this was patched in a later release)
  2. If you’re self-hosting, try running npm update n8n or pull the latest Docker image
  3. As a temporary workaround, skip the credential test and just use the credential directly in an OpenAI node with a test run - if the API key is valid, the node itself will work even if the credential tester throws this error

Could you share which n8n version you’re running? That would help narrow it down.

I’ve gotten the same error and have spent some time troubleshooting it before coming to the forum for help, and this post just pops out right in front :slight_smile: Here’s my environment info:

Debug info

core

  • n8nVersion: 2.19.2
  • platform: docker (self-hosted)
  • nodeJsVersion: 24.14.1
  • nodeEnv: production
  • database: sqlite
  • executionMode: regular
  • concurrency: -1
  • license: enterprise (production)
  • consumerId: XX

storage

  • success: all
  • error: all
  • progress: false
  • manual: true
  • binaryMode: filesystem

pruning

  • enabled: true
  • maxAge: 336 hours
  • maxCount: 10000 executions

client

  • userAgent: mozilla/5.0 (macintosh; intel mac os x 10_15_7) applewebkit/537.36 (khtml, like gecko) chrome/147.0.0.0 safari/537.36
  • isTouchDevice: false

Hi,

Thank you for your detailed answer! You were right, it’s clearly a version bug.

Here’s my current situation:

  • I’m running n8n 2.19.3 on Docker (self-hosted on Hostinger)

  • I tried to update n8n via terminal using docker compose pull and docker compose down && docker compose up -d

  • I also asked Hostinger’s assistant (Kodee) for help

  • But after all of this, n8n is still on version 2.19.3

It seems like the latest Docker tag is currently pointing to 2.19.3, so I can’t go higher for now.

Do you know if the patch has been released in a version above 2.19.3? Or should I try to force a specific version in my docker-compose.yml?

Thanks again!

Hi,

Thanks for sharing your debug info, our setups look very similar!

Here’s mine:

  • n8n version: 2.19.3

  • Platform: Docker (self-hosted on Hostinger)

  • Database: SQLite

  • Mode: production

Just like you, I’ve been stuck on this bug. I tried updating via terminal (docker compose pull + restart) and even contacted Hostinger’s support assistant, but n8n still stays on 2.19.3.

Did you find any workaround on your end? Did forcing a specific version in docker-compose.yml work for you?

Would love to know if you managed to fix it!

Thanks

As suggested by Nguyen, I triggered my workflow despite the credential test error and it works fine (with a valid API key). Most likely a bug where the error gives false alarm.

Unfortunately, doesn’t work for me…

same problem same scenario,just got to hostinger then making some credentials then im stock with

this

The same issue and error with n8n 2.19.4 run via docker

Hi Shinygami,

I have updated my n8n to the latest stable version (2.19.4) but still encounter the same issue. I guess this needs the attention from n8n support team.

Meanwhile, may I know what’re you trying to achieve? Perhaps there are some alternatives to temporarily work around the issue while waiting for n8n R&D team to fix the issue. If it’s an AI chatbot (with OpenAI LLM model), then you may try using OpenAI Chat Model node instead (as below).

The OpenAI Chat Model node is able to return the list of available model despite the connection error.

Hope this helps.

THX, it works with AI Agent despite returning the error.

yeah it works,i didnt expect this to go on thats why i didnt try but it actually works,tnx my brother

thx it’s working also for me ! I have to create my entire workflow again and modify everything XD
By any chance, do u have an idea when the problem will be solved completly by n8n ?

Hey everyone — if you’re experiencing this issue, it appears to be a recent bug in the n8n OpenAI configuration.

Right now, the workaround is to bypass the built-in OpenAI node and manually connect to OpenAI using an HTTP Request node instead.

Why this works:
The issue seems to be tied to the current n8n OpenAI configuration. By sending a direct API HTTP request to OpenAI, you’re essentially creating a fresh connection that avoids the bug completely.

How to get started:

  1. Click the “+” button in n8n

  2. Search for “HTTP Request”

  3. Add the HTTP Request node to your workflow

From there, use ChatGPT to guide you step-by-step through the setup process. A very easy method is:

• Complete one step
• Take a screenshot
• Send it to ChatGPT
• Ask for the next step

Repeat that process until your OpenAI API is fully connected and working.

The setup takes a little longer, but it works extremely well.

I personally tried all of the other suggested fixes people mentioned, and none of them solved the issue for me — but this method did.

Please reply and let me know if it worked for you.

Best regards,
Drew

I learnt from another thread that this issue has been confirmed as a bug in n8n version 2.19.3 and 2.19.5. The bug is tracked here: HTTP Request node fails with "config.headers.setContentType is not a function" when calling api.openai.com · Issue #29471 · n8n-io/n8n · GitHub

OpenAI credentials can be finicky if the API key wasn’t copied correctly or if there’s an extra space at the end. I’d also make sure you have a valid billing method on your account, as that’s a common reason for hidden failures.