I have my docker-compose orchestration and I'm getting this error:
connection error: { MongoError: failed to connect to server [172.17.0.2:27018] on first connect [MongoError: connect ECONNREFUSED 172.17.0.2:27018]
This is the code in server.js:
mongoose.connect('mongodb://mongodb:27018');
This happen only when I customize the command of my docker container:
docker-compose.yml:
version: "3"
services:
app:
build: ./my-node-app
depends_on:
- mongodb
mongodb:
image: mongo:3.5
command: mongod --port 27018
If I remove the --port 27018 and point to the default 27017 the error gets fixed.
What could be happening?