I would like to install Mongodb on IntelliJ (already with Angular and Node.js). I installed MongoDB and changed my environment variables. I use Windows 10. When I try the command line : "mongo dbs show", I get this error :
MongoDB shell version v3.4.10 connecting to:
mongodb://127.0.0.1:27017/dbs 2017-11-20T16:59:43.003+0100 W NETWORK
[thread1] Failed to connect to 127.0.0.1:27017 after 5000ms
milliseconds, giving up. 2017-11-20T16:59:43.003+0100 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
In order to fix it, I tried the instructions of related posts, that is to say :
-Create a data directory in "MongoDB\Server\3.4\data"
-Change the directoy "mongod --dbpath=..."
-Change the allowed port to 27017 thank to "add --port 27017"
I did those operations but it doesn't solve the problem. Would you know how to fix it ? I thank you very much in advance !
Related
I just completed an installation of mongodb in my computer and, after starting and enabling it I keep getting the same error:
MongoDB shell version v4.2.23
connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
2022-11-10T16:25:32.787+0100 E QUERY [js] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed: SocketException: Error connecting to 127.0.0.1:27017 :: caused by :: Connection refused :
connect#src/mongo/shell/mongo.js:353:17
#(connect):2:6
2022-11-10T16:25:32.788+0100 F - [main] exception: connect failed
2022-11-10T16:25:32.788+0100 E - [main] exiting with code 1
I uninstalled and installed multiple times and tried solutions that worked for other people in similar posts but I can not make it work.
I have a feeling it have something to do with the port it is looking for (27017) but I do not know how to check if that is the problem and, if so, how to fix it.
Thanks!
Here are a few things to consider:
Check if the MongoDB process is running (you can verify using ps, netstat (check listen port) command in the server.
See if your MongoDB service runs locally. That is because by default, the listen address of MongoDB is localhost/loopback.
Check if the firewall is running and you have allowed the port.
Verify if you are able to use telnet to command the port 27017 from the application server.
I downloaded mongodb-bin and mongodb-tools-bin in AUR.I just typed sudo systemctl enable mongodb and just ran mongo.This is the error i got:
$ mongo
MongoDB shell version v5.0.5
connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed: SocketException: Error connecting to 127.0.0.1:27017 :: caused by :: Connection refused :
connect#src/mongo/shell/mongo.js:372:17
#(connect):2:6
exception: connect failed
exiting with code 1
I saw somebody say to just delete /var/lib/mongodb/mongod.lock but when i checked there was no mongod.lock file
I have fixed the problem by deleting /tmp/mongodb-27017.sock.I have found the answer here
I have a server running node and mongoDB. Mongo is suddenly throwing errors, I managed to get it started upon rebooting the server but the error reappears upon trying to handle a request.
The error when I try to run mongo in a shell is:
MongoDB shell version v4.4.6
connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed: SocketException: Error connecting to 127.0.0.1:27017 :: caused by :: Connection refused :
connect#src/mongo/shell/mongo.js:374:17
#(connect):2:6
exception: connect failed
exiting with code 1
My mongod.conf has the correct data path and I also tried setting it manually using mongod --dbpath and can confirm that it is correct.
mongod --repair doesn't work either.
Any ideas?
Turns out the server was out of storage. Running df showed that there was no disk space left.
I ended up adding a volume and moving my database and files there.
When I try to launch the mongo shell running the 'mongo' command in the terminal I get this error:
connecting to: mongodb://127.0.0.1:27017
2017-12-23T17:52:51.318+0100 W NETWORK [thread1] Failed to connect to
127.0.0.1:27017, in(checking socket for error after poll), reason:
Connection refused
2017-12-23T17:52:51.319+0100 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 cannot figur out what is the problem...
First, you need to check whether mongo server is running on your local system by visiting below url in the browser.
http://127.0.0.1:27017
you can run the below command in case of ubuntu.
$ sudo service mongod start
Then, Run:
$ mongo
My problem here is that even after setting up mongod.exe "mongod.exe --install --logpath c:\mongodb\logs --logappend --dbpath c:\mongodb\data\db --directoryperdb", when i start up mongo.exe on another shell, i get a connection error
MongoDB shell version: 3.2.9
connecting to: test 2016-10-01T17:20:11.543+0300 W NETWORK [thread1] Failed to connect to 127.0.0.1:27017 after 5000 milliseconds, giving up.
2016-10-01T17:20:11.543+0300 E QUERY [thread1] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed : connect#src/mongo/shell/mongo.js:229:14
#(connect):1:6
exception: connect failed
what is it that i'm not doing right? Running it on Windows 10. Mongod.exe after set up waits for a connection.
it is may be because of the OS privileges so for example if you are in
windows try to open the cmd(command line) in administrator mode and
try to start the MongoDB server again,i hope this fix your problem
This is because the db server must be running and waiting for connections. I think you should start your db server first with ./mongod in the root directory and leave it running. Hopefully this will help!