[MongoDB] SocketException: Error connecting to 127.0.0.1:27017
Bonjour
Voici les versions Mongo et Ubuntu utilisées:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| (base) avy@machine:~$ mongod --version
db version v5.0.10
Build Info: {
"version": "5.0.10",
"gitVersion": "bbf5bc7e16d1713c9349a09adf4901ca37472e66",
"openSSLVersion": "OpenSSL 1.1.1 11 Sep 2018",
"modules": [],
"allocator": "tcmalloc",
"environment": {
"distmod": "ubuntu1804",
"distarch": "x86_64",
"target_arch": "x86_64"
}
} |
Pour des raisons que j'ignore mongod/mongo ne fonctionne plus:
Code:
1 2 3 4 5 6 7 8 9
|
(base) avy@machine:~$ mongo
MongoDB shell version v5.0.10
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 |
En premier lieu j'ai regardé à qui appartenait le dbPath et le fichier log et le soucis ne s'y trouve pas.
Code:
1 2 3 4 5
|
(base) avy@machine:~$ ls -l
drwxrwxrwx 5 avy mongodb 4096 août 6 13:08 mongodatabases
(base) avy@avywam:/var/log/mongodb$ ls -l
-rw------- 1 mongodb mongodb 114821299 août 7 16:44 mongod.log |
J'ai tenté quelques "solutions" qui n'ont pas fonctionné dans mon cas:
Code:
1 2 3 4
|
sudo rm /var/lib/mongodb/mongod.lock
mongod --repair
sudo service mongodb start |
J'ai mis le dossier /var/lib/mongodb comme étant exclusivement au groupe mongodb, rien n'y fait.
J'ai aussi rendu /tmp/mongodb-27017.sock comme étant exclusivement au groupe mongodb, car il était l'exclusivité de root, mais ça n'a pas réglé le problème
Code:
1 2 3
| (base) avy@machine:/tmp$ sudo chown mongodb:mongodb mongodb-27017.sock
(base) avy@machine:/tmp$ ls -l
srwx------ 1 mongodb mongodb 0 août 7 15:27 mongodb-27017.sock |
Je reste bloquée sur ce problème:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13
|
(base) avy@machine:$ sudo service mongod restart
(base) avy@machine:$ sudo service mongod status
● mongod.service - MongoDB Database Server
Loaded: loaded (/lib/systemd/system/mongod.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Sun 2022-08-07 17:09:31 CEST; 6min ago
Docs: https://docs.mongodb.org/manual
Process: 7559 ExecStart=/usr/bin/mongod --config /etc/mongod.conf (code=exited, status=100)
Main PID: 7559 (code=exited, status=100)
août 07 17:09:31 machine systemd[1]: Started MongoDB Database Server.
août 07 17:09:31 machine systemd[1]: mongod.service: Main process exited, code=exited, status=100/n/a
août 07 17:09:31 machine systemd[1]: mongod.service: Failed with result 'exit-code'. |
Les configurations sont très classiques:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| # mongod.conf
# for documentation of all options, see:
# http://docs.mongodb.org/manual/reference/configuration-options/
# Where and how to store data.
storage:
dbPath: /home/avy/mongodatabases
journal:
enabled: true
# where to write logging data.
systemLog:
destination: file
logAppend: true
path: /var/log/mongodb/mongod.log
# network interfaces
net:
port: 27017
bindIp: 127.0.0.1
# how the process runs
processManagement:
timeZoneInfo: /usr/share/zoneinfo |