I'm running a Node.js app inside Docker and trying to connect to a MongoDB instance running on my host machine. The connection string mongodb://localhost:27017 fails inside the container.
Error: connect ECONNREFUSED 127.0.0.1:27017
I know localhost inside Docker refers to the container itself. How do I properly connect to the host's MongoDB?
Sofia Greco
asked 2 months ago1
Answers19
Upvotes6150
Views