i am a front stack dev trying to become full stack, been learning node and express and wanted to start with mongo, i went to the officlal mongodb page and followed the instruction to download mongo trough the cli in ubuntu 20.4
finished with the commands, i typed mongo in the command line and get this in mi cli
MongoDB shell version v4.4.4 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
what is that? im new at this side of coding and feel a bit overwelm by this, i appreciate the help you would give me
i had a similiar issue this probably happened because you failed to start mongodb service before opening the mongo shell.
next time run the command
sudo systemctl start mongod
this helps to start the mongodb service
to check if the service is running successfully you can then run the command
sudo systemctl status mongod
after which you can proceed to run the command
mongo
to run the mongo shell. this hack only applies to ubuntu system.
Related
I've got problem with running mongodb on wsl ubuntu.
During using powershell everything works fine. I type node db.js and its working. After switching terminal to ubuntu and run the same command i get an error: "MongoServerSelectionError: connect ECONNREFUSED 127.0.0.1:27017".
Any idea how to resolve this problem?
Try to check mongod service status via cli
use service mongod status to check
If it's not active then try to activate
use this sudo service mongod start
If mongod service is not found then try to install the mongodb
I am making an app on Node.js and trying to connect to MongoDB via mongoose. When I run it, in cmd it shows "connected to MongoDB database", but this is what it shows when I run mongo. It doesn't say connected
Mongo connection status
Also, when I try to connect MongoDB compass to localhost:27017, it shows the error " read ECONNRESET".
So clearly, for some reason, my MongoDB is not connected to the localhost. Can someone help me out? here is my mongoose connection code in app.js.
App.js Mongoose connection code
Can you check your mongod.conf file to see the port the server is set to run on.If on linux and running as a service use systemctl status mongod to ensure the process is running. Hope it helps.
Maybe you should run the command- " mongod " in another window and check.
If it's not connecting, simply go in that path:
C:\Program Files\MongoDB\Server\5.0\bin
and click shift + right, open window PowerShell or any other command prompt, and then type mongod like that:
PS C:\Program Files\MongoDB\Server\5.0\bin> mongod
and connect to it again.
Just followed these simple steps:
Type here to search -- Services -- Click on that
Find -- MongoDB Server(MongoDB) -- Click on that
On the left site of window You will see -- Start-- link. Click on that,
and your problem is solved.
I installed Robo 3T and after the installation, when I tried to create my first database, a error message popped up telling me the following:
Failed to connect to localhost:27017
What could be the cause of this issue?
Please check if your mongodb service has started or not.
If running latest version of windows search of mongod in programs and run that or pathToMongo/Server/{your version}/bin and run mongod.exe
Mongo shell not connecting
I have dedicated centos server
I installed mongodb as a service in my server from here
I even restarted server after installing mongodb
When i tries to run mongo shell it always saying
Error: couldn't connect to server 127.0.0.1:27017 (127.0.0.1), connection attempt failed at src/mongo/shell/mongo.js:146
I tried to remove that mongod.lock but no joy
I dont understand why this happens, because when mongod starts as a service it creates a log in system and telling that it has opened the door to listen incoming connection on port 27017. But it is throwing error while i connecting to mongo shell.
Please see this steps i have used --> click here
Well i wants to use this mongo service first of all at local based with only 127.0.0.1 access. I can change that in mongod.conf file afterward.
Be sure with iptables, Firwalll causing this kind of issue on live server.
So please do this if you facing this kind of same issue,
Do iptables off for a moment
# /etc/init.d/iptables stop
# sudo service mongod start
# mongo
Here what i wanted to see finally,
MongoDB shell version: 2.6.7
connecting to: test
Welcome to the MongoDB shell.
For interactive help, type "help".
For more comprehensive documentation, see
http://docs.mongodb.org/
Questions? Try the support group
http://groups.google.com/group/mongodb-user
show dbs
admin (empty)
local 0.078GB
Thanks guys who considered my question and looking in it.
Thanks a lot.
I downloaded postgresql-9.1.
but when I execute the command in terminal:
$ createdb mydb
I get the following message:
createdb: could not connect to database postgres: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
please tell me how to sort this problem.I have even tried to uninstall and then reinstall it. I am trying to run this on linux mint 15 (cinnamon).
Use ps to see if the postgresql process is actually running. If not, start it (service postgresql start). Normally should start up itself on boot after installation but who knows. Also, some error may prevent it from starting on boot.
If postgresql is running, then you may need to edit pg_hba.conf in the data directory. Again, normally the database should listen for local connections by default but who knows.