ECONNREFUSED error when connecting to mongodb from node.js

前端 未结 13 1279
不思量自难忘°
不思量自难忘° 2020-11-27 05:51

I know I\'m doing some very stupid and noobish, but I\'m hoping someone can help me set up a basic database connection to mongodb from node.js on a mac.

I\'ve instal

13条回答
  •  面向向阳花
    2020-11-27 06:38

    I also got stucked with same problem so I fixed it like this :

    If you are running mongo and nodejs in docker container or in docker compose

    so replace localhost with mongo (which is container name in docker in my case) something like this below in your nodejs mongo connection file.

    var mongoURI = "mongodb://mongo:27017/";
    

提交回复
热议问题