No connection could be made because the target machine actively refused it?

commands used
to create the mongod server

mongod --dbpath /data/db --port 27000 --bind_ip "localhost,192.168.103.100" --auth

to create the user as explained in the lessons using another terminal:

mongo admin --host localhost:27000 --eval '
 db.createUser({
user: "m103-admin",
pwd: "m103-pass",
roles: [
  {role: "root", db: "admin"}
]
})
'

error:
MongoDB shell version v4.0.10
connecting to: mongodb://localhost:27000/admin?gssapiServiceName=mongodb
2019-09-24T17:59:01.950+0200 E QUERY [js] Error: couldn’t connect to server localhost:27000, connection attempt failed: SocketException: Error connecting to localhost:27000 (127.0.0.1:27000) :: caused by :: No connection could be made because the target machine actively refused it. :
connect@src/mongo/shell/mongo.js:344:17
@(connect):2:6
exception: connect failed

Is your mongod up and running on port 27000?
Error says could not connect
Please check ps -ef|grep mongod

1 Like

Hi @Abdelrahman_Torki,

In addition to what @Ramachandra_37567 mentioned, please also confirm if you have done ssh into vagrant in your second terminal.

Thanks,
Muskan
Curriculum Support Engineer

1 Like

yes, I forget to do ssh. Thanks a lot!