I’m really new to MongoDB and I’m trying to connect to MongoDB locally in order to be able to develop a project but am coming into issues that I don’t really understand, so hoping for some help.
{"t":{"$date":"2022-03-03T07:50:40.907-05:00"},"s":"E", "c":"CONTROL", "id":20568, "ctx":"initandlisten","msg":"Error setting up listener","attr":{"error":{"code":9001,"codeName":"SocketException","errmsg":"Address already in use"}}}
Let me know if you need anymore information. This is my first time setting up something like this so I am a bit out of my depth.
After talking through with a colleague, I managed to solve the problem. Sharing here in case someone has a similar issue.
Although I couldn’t see mongod in the above command I ran sudo lsof -iTCP -sTCP:LISTEN -n -P and then killed the mongod port kill 22311
After that I got a different error:
{"t":{"$date":"2022-03-03T08:19:38.033-05:00"},"s":"E", "c":"CONTROL", "id":20557, "ctx":"initandlisten","msg":"DBException in initAndListen, terminating","attr":{"error":"NonExistentPath: Data directory /data/db not found. Create the missing directory
So I created a folder with a path ~/data/db and then restarted mongod sudo mongod --dbpath=Documents/Code/mongodb/data/db