N8n api node cannot connect

I am trying to backup/create versions of my workflows with this workflow.

And I cannot get the n8n api node to connect to my n8n instance. I always get following error(replaced my domain with “example.com”):

Screenshot

When I try to connect to the swagger api playground everything works, after inputting the api key I can make all requests.

I guess it has to do something with how I am hosting this n8n instance, I’ve used the official step-by-step guide with traefic to host it right now.

I’ve tried to use the internal ip:port of the n8n docker instance and my domain.

n8n Version: 0.212.0

Yes, my assumption would also be that n8n can not reach itself via that URL. If it could it should work.

You could try: http://localhost:5678/api/v1

Hi @jan, thanks for your quick response.

I’ve just tried http://localhost:5678/api/v1 and https://localhost:5678/api/v1.
Both did not work.

I am still a complete noob with traefik and in general with proxies, so I do not really have any ideas on where the problem lies.

Added n8n Version to main post (0.212.0)

Very strange. And the port n8n uses did not get changed? It is really 5678?

I’ve not changed the port /:

Screenshot

afaik my install is 1 to 1 like the guide in your docu.

What does it display when you click on “More details”

I tried with multiple addresses and I got different errors:

1 Error

The service refused the connection - perhaps it is offline

Screenshot

grafik

“public ip”:5678/api/v1
“public ip”/api/v1
n8n.example.com/api/v1
https://localhost/api/v1

public ip cannot work, as the docker is not exposed directly to it, traefik only passes traffic to n8n on n8n.example.com
also public ip or localhost without port totally makes sense why this error gets thrown - a port is needed in this case else it does not get forwarded to the right port.

2 Error

UNKNOWN ERROR - check the detailed error for more information

Screenshot

grafik

https://localhost:5678/api/v1
https://127.0.0.1:5678/api/v1

I think this error happens because https is not supported/enabled on the n8n docker directly. I am using traefik for https which only works (in my case) on n8n.example.com

3 Error

Authorization failed - please check your credentials

Screenshot

grafik

http://localhost:5678/api/v1
http://127.0.0.1:5678/api/v1

As that error suggests, it can establish a connection I’ve tried to insert a fresh copy of the api key which did not help. when I use the same copy of the api key in swagger it works.

Screenshot

grafik

(Just got an idea writing this: swagger works → that should mean, that from another n8n instance I should be able to connect.)

Generating a new api key also does not work.

EDIT: just realized, the screenshot of swagger also shows “authorized” when using a false api key, but when copying the right api key into swagger i can use all calls i tried without problems.

EDIT 2:
I’ve just tried to connect from an n8n cloud instance to my self-hosted n8n instance and I also get the same error:

Screenshot

grafik

EDIT 3:
when connecting from the cloud instance to the cloud instance it works:
when connecting from the self-hosted instance to the cloud instance it also works:

Screenshot

grafik

It probably has nothing todo with my current problem, but the n8n docker log gets spammed with following error:

Summary

I just had the same issue. By inspecting the network request, I’ve found out the api key was changed after copy/pasting. After switching the API key field from Fixed to Expression (so the key was visible) and pasting it there, I was able to pass the credentials test.

Unfortunately it still gets replaced (from n8n_api_... to something like n8n_BLANK_VALUE_...) when closing the dialog. Can someone from n8n look into this?

EDIT: unfortunately I was wrong. Seems like the credentials test is just not fired at all if I use expression

I see a similar issue in Backups n8n Workflows, that wasn’t solved actually. It seems there is some issue with the self-hosted instance accessing itself.

Setting http://localhost:5678/api/v1 as baseUrl has the same problem (Authorization failed - please check your credentials), so I am not sure it is caused by proxy. I assume it is able to reach the instance, since the error is different if it is pointing to a non-existent/other url

Playground works fine for me with the correct key, doesn’t work with any other

I had the same issue with it replacing the api key to something like n8n_BLANK_VALUE_...) but I never paid close attention to this.

Interestingly I also cannot connect from the cloud instance to the self-hosted instance (I’ve only tried my self-hosted n8n which is behind a proxy)

I’ve also got an instance running without a proxy, I’ll try if the issue persists there too.

Just tried it on my local self-hosted (Version 0.212.1) and I’ve got the same problems with that instance.

Screenshot

@jan If you need any additional information I happy to provide it :slight_smile:

- N8N_AUTH_EXCLUDE_ENDPOINTS=api
I had to add this to my docker-compose file’s environment section and it solved my api problems. It seems that BASIC_AUTH doesn’t play nice in this situation.

1 Like