Connect ECONNREFUSED 0.0.4.210:27017

Describe the problem/error/question

What is the error message (if any)?

when creating MongoDB credentials, Regardless of whether host.docker.internal or specific ip:192.168.65.254 is filled in the host, n8n keeps reporting the same error:connect ECONNREFUSED 0.0.4.210:27017

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.)

Share the output returned by the last node

Information on your n8n setup

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

Hello @guanqihuishuai hope all is good, Welcome to the community. Could you please tell/show us

  • how you are running your n8n (npm, docker)
  • how you are running mongo (local, docker)
  • whether you are using docker compose for both services
  • the credentials window with the error

If in docker (assuming from show the output of docker ps -a.

1 according to Docker Desktop for Windows to running n8n

2 local

3 only n8n running in docker

4 Couldn’t connect with these settings

connect ECONNREFUSED 0.0.4.210:27017

If you are running n8n in docker container, and mongo locally on your host, then on windows “host.docker.internal” should do the trick.

What I would check is which IP the socket is bound to: in powershell run
netstat -ano | findstr 27017

This should tell us more.

You could attempt to connect to 172.17.0.1 too, but my biggest suspect is that your mongo is either not listening or listening on 127.0.0.1.

I use host.docker.internal, but also reporting the same error:connect ECONNREFUSED 0.0.4.210:27017. and result of is netstat -ano | findstr 27017

netstat -ano | findstr 27017
TCP 0.0.0.0:27017 0.0.0.0:0 LISTENING 23300

before that I set bindIp is 127.0.0.1, but also reporting the same error, later I modify bindIP to 0.0.0.0

I’ve tried everything I could. but n8n keeps reporting the same error:connect ECONNREFUSED 0.0.4.210:27017. I don’t know where 0.0.4.210 this ip comes from?

Is your n8n container connected to the brindge network or host network?

bridge network

Can you post your answer again, it got caught by the filter for some reason

n8n container connect to the brindge network

“NetworkMode”: “bridge”

Good. Regarding the mongo, is there a reason you are not running it in the container too?

Mongo can run in a container. If it is modified to run in a container, what should be filled in the host?

I have already deployed MongoDB into a container (the container name is mymongo), but the same error still occurs.

It has been tested in the container, the ip and port are connected, no problem

Yes, in case of a container the destination is the container name (mymongo should work). If you are getting the same error, something is definitely wrong.

Instead of wget, could you run curl? Since it’s not installed, run

docker exec -it --user root n8n /bin/sh -c "apk update && apk add curl && curl -v mymongo:27017"

by the way, what happens if you just use any random ip?
are you running any proxy anywhere?

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