MongoDB.live, free & fully virtual. June 9th - 10th. Register Now

Error: couldn't connect to server - Linux -

$ sudo apt-get install -y mongodb-org
Reading package lists… Done
Building dependency tree
Reading state information… Done
mongodb-org is already the newest version (4.2.6).
You might want to run ‘apt --fix-broken install’ to correct these.
The following packages have unmet dependencies:
mongodb-org : Depends: mongodb-org-server but it is not going to be installed
Depends: mongodb-org-mongos but it is not going to be installed
Depends: mongodb-org-tools but it is not going to be installed
E: Unmet dependencies. Try ‘apt --fix-broken install’ with no packages (or specify a solution).

:~$ mongo
MongoDB shell version v4.2.6
connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
2020-04-27T12:29:07.313-0500 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:341:17
@(connect):2:6

after launch :~$ ss -tlnp
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 80 127.0.0.1:3306 0.0.0.0:*
LISTEN 0 128 127.0.0.53%lo:53 0.0.0.0:*
LISTEN 0 5 127.0.0.1:631 0.0.0.0:*
LISTEN 0 128 :80 :
LISTEN 0 5 [::1]:631 [::]:

What need to do?

Start a mongod that listen to 127.0.0.1:27017.

Or specify the appropriate server when running mongo.

Apt is not happy here. run the fix suggested by the output.

Did you try installing mongo from the system’s repos before adding mongodb.org ?

fixed by :" You need to first uninstall the mongodb, you can use:

sudo apt-get purge mongodb-org*

After this, install mongodb through the following commands:

sudo apt-get install mongodb

And then update:

sudo apt-get update

You are done with the installation of mongodb. You can check it by using the below command:

mongo --version
```"

nothing

from this page … like tutorial – https://docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu/

and nodejs install mongodb

:~$ sudo apt --fix-broken install
[sudo] password for forperuse:
Reading package lists… Done
Building dependency tree
Reading state information… Done
Correcting dependencies… failed.
The following packages have unmet dependencies:
mongodb-org : Depends: mongodb-org-server but it is not installed
Depends: mongodb-org-mongos but it is not installed
Depends: mongodb-org-tools but it is not installed
E: Error, pkgProblemResolver::Resolve generated breaks, this may be caused by held packages.
E: Unable to correct dependencies

i don’t know how to do this, can you give to me the solutions, how can to do that with command line?

It is not clear what problem you are trying to fix. From some of the post it looks like you are trying to fix an installation issues. My reply was to fix

To start a localhost server use the documentation found at https://docs.mongodb.com/manual/reference/program/mongod/

To connect to another server with the mongo command consider the manual at https://docs.mongodb.com/manual/reference/program/mongo/

What flavor and version of linux are you installing on.