Unable to connect to MongoDb m312 lab

Hi,
I use the lab on Windows 11.
I run mongod --port 27000 in one command prompt window.
The last message is: I NETWORK [thread1] waiting for connections on port 27000
Then I opened another command prompt window and issued mongod --port 27000 but I get the following:

2022-05-11T08:42:08.492+0000 I CONTROL [initandlisten] options: { net: { port: 27000 } }
2022-05-11T08:42:08.492+0000 I STORAGE [initandlisten] exception in initAndListen: 98 Unable to lock file: /data/db/mongod.lock Resource temporarily unavailable. Is a mongod instance already running?, terminating
2022-05-11T08:42:08.492+0000 I NETWORK [initandlisten] shutdown: going to close listening sockets…
2022-05-11T08:42:08.492+0000 I NETWORK [initandlisten] shutdown: going to flush diaglog…
2022-05-11T08:42:08.492+0000 I CONTROL [initandlisten] now exiting
2022-05-11T08:42:08.492+0000 I CONTROL [initandlisten] shutting down with code:100

How can I connect to the mongodb database?

Hi @Enrico_Bevilacqua,

Welcome to the MongoDB University Forums :sparkles:

Can you try executing the command mongo within your cmd instead of mongod --port 27000?

In case you have any doubts, please feel free to reach out to us.

Thanks,
Kushagra Kesav

Hi Kushagra_Kesav

I did it. I run the mongo command and I get the following:

MongoDB shell version v3.4.2
connecting to: mongodb://127.0.0.1:27017
2022-05-11T09:45:33.476+0000 W NETWORK [thread1] Failed to connect to 127.0.0.1:27017, in(checking socket for error after poll), reason: Connection refused
2022-05-11T09:45:33.476+0000 E QUERY [thread1] Error: couldn’t connect to server 127.0.0.1:27017, connection attempt failed :
connect@src/mongo/shell/mongo.js:237:13
@(connect):1:6
exception: connect failed

I don’t know if I did something wrong to follow the instructions to Installing Vagrant for M312 but now I’m stucked to go ahead with M312 course and I don’t know how to solve.
I searched on the forum but I didn’t find anything useful to me to solve the issue.
I tried some of the suggetions in reply to my post but it didn’t work for me.
Any help will be appreciated.

When you start mongod on a different port than the default port like you did with:

You must use mongo with the same port number. That is meant by

The --port part was correct, the command name has to be changed from mongod to mongo (or mongosh).

If you are unclear about the difference between the server and client, start by taking M001 and M103.

Thank you Kushagra_Kesav, I misinterpreted what you tell me, now I’m connected.

1 Like

And thanks to steevej for making you realized that you misinterpreted what Kushagra_Kesav wrote.

Yes, thank you too, sorry.

1 Like

Same problem i am facing

If you are facing the same issue please try the same solution.

The solution being Do not Start mongod twice.