0

I was doing a mongodb tutorial and now all of a sudden I cannot connect. I have tried all sorts of things and nothing is working. when I copy and paste the string from the cluster (which worked 3 hours ago) it says

QUERY    [js] Error: couldn't connect to server .:27017, connection attempt failed:      HostNotFound: Could not find address for .:27017: SocketException: Host not found (authoritative)    :

so I did some googling and found all kinds of stuff about mongod. so when I type in mongod it fails because there is no /data/db folder. so I followed the top answer from here to create the directory. it says the directory still does not exist. I am looking in my finder and that folder does in fact exist. so I'm not sure what's happening there.

I tried mongod --port 27018 but it fails because

exception in initAndListen: NonExistentPath: Data directory /data/db not found., terminating

but again that folder exists. I am looking at it. it currently contains a txtfile called 'you_stupid_fucking_dumbass_computer_why_cant_you_see_this.txt'. according to the terminal, that file does indeed exist in the /data/db folder which exists exactly where I created it as directed in the hyperlink. I used the accepted answer. not sure why it' failing.

I have been searching all over stack overflow and have tried all variety of answers to no effect. if you are going to recommend anything that involves homebrew, just know that any homebrew command fails because it cannot recognize 'services'. I have tried them all but have found no luck. I tried killing by the pid but that didn't work either because no matching processes are found. I have tried various 'killall' things too and none of them work. same reason. command isn't recognized. so there's that too. please help

amnmustafa15
  • 121
  • 1
  • 14

1 Answers1

0

If you check the Activity Monitor on Mac or Resource Monitor on Windows, you may find that your use of that port was never terminated. This prevents subsequent uses. You can disconnect before ending a session, or use the Activity Monitor to do it manually. There's also ways of doing this in the command line.

This may or may not help, but I had this issue before, where all of a sudden I couldn't use MongoDB and it was simply due to not disconnecting from the port when finished.

27017 could be circumvented by using 27018 as well, but probably best to just clear up and reuse the default.

Matthew
  • 91
  • 3
  • 10
  • 1
    I said in my question that changing to port 27018 doesn't work for the same reason. it says there's no /data/db folder. but there is. – amnmustafa15 Feb 26 '20 at 01:35
  • just tried that. cancelled all mongo related processes. exact same result. would uninstalling and reinstalling solve it? – amnmustafa15 Feb 26 '20 at 01:37
  • I'm not sure about installing and uninstalling. I know that on Mac when OS Catalina came out I had an issue with the /data/db folder. I had to put the folder in a new location. – Matthew Feb 26 '20 at 01:55
  • https://stackoverflow.com/questions/58283257/mongodb-cant-find-data-directory-after-upgrading-to-mac-os-10-15-catalina – Matthew Feb 26 '20 at 01:56
  • https://www.reddit.com/r/mongodb/comments/d7takd/macos_x_catalina_105_beta_and_mongo_a_warning/ – Matthew Feb 26 '20 at 01:57