Rest API not working after switch to NPM

Describe the problem/error/question

I was using N8N Rest API and it was working on the desktop version. Now I switched n8n to npm version and the API ist not working any more. I am calling it via http://localhost:5678/api/v1/workflows?active=true&limit=100’ using newly generated API KEY.
I also tried with API playground and there it is working fine.

What is the error message (if any)?

ERROR: The service refused the connection - perhaps it is offline
connect ECONNREFUSED ::1:5678

Please share your workflow

Share the output returned by the last node

Information on your n8n setup

  • n8n version: 1.16.0
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main): default
  • Running n8n via (Docker, npm, n8n cloud, desktop app): npm
  • Operating system: Windows 11 Pro

First important to mention that there is an n8n node so there should be no need to use an HTTP Request node.

About your problem. It seems like n8n does not potentially not run on port 5678 rather another one.

What is the URL you access the UI with? That one should give you a good idea of how the access the API.

I am using http://localhost:5678/ to access the UI.

Hey @pghahrem,

I have a theory… can you try swapping out localhost for or the local ip for your machine and see if that works.

The default localhost is In Windows I added to the hosts file. Then I can reach the UI via both IPs. But the problem still persists also in

This is happening because localhost is resolving to ::1 (IP v6), and n8n isn’t listening to that IP because N8N_LISTEN_ADDRESS defaults to (all IP v4).
Please try setting N8N_LISTEN_ADDRESS to ::.

Another option would be to force n8n to use IPv4 by setting NODEJS_PREFER_IPV4 to true.


Hi @netroy ,
your hint worked perfectly :slightly_smiling_face:. Thanks alot for your help :+1:.

1 Like

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