I created an ssh key for my vps today. When I then restarted the vps and tried running 'mongo' or 'mongod' im getting these errors:
For mongo:
connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
2019-12-08T18:14:02.345+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:341:17
@(connect):2:6
2019-12-08T18:14:02.347+0100 F - [main] exception: connect failed
2019-12-08T18:14:02.347+0100 E - [main] exiting with code 1
For Mongod:
2019-12-08T18:09:50.619+0100 I CONTROL [main] Automatically disabling TLS 1.0, to force-enable TLS
1.0 specify --sslDisabledProtocols 'none'
2019-12-08T18:09:50.623+0100 I CONTROL [initandlisten] MongoDB starting : pid=1169 port=27017
dbpath=/data/db 64-bit host=1cc0f81c.cus9089.kvm.st-srv.eu
2019-12-08T18:09:50.623+0100 I CONTROL [initandlisten] db version v4.2.1
2019-12-08T18:09:50.623+0100 I CONTROL [initandlisten] git version:
edf6d45851c0b9ee15548f0f847df141764a317e
2019-12-08T18:09:50.623+0100 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.1.1b 26 Feb 2019
2019-12-08T18:09:50.623+0100 I CONTROL [initandlisten] allocator: tcmalloc
2019-12-08T18:09:50.623+0100 I CONTROL [initandlisten] modules: none
2019-12-08T18:09:50.623+0100 I CONTROL [initandlisten] build environment:
2019-12-08T18:09:50.623+0100 I CONTROL [initandlisten] distmod: ubuntu1804
2019-12-08T18:09:50.623+0100 I CONTROL [initandlisten] distarch: x86_64
2019-12-08T18:09:50.623+0100 I CONTROL [initandlisten] target_arch: x86_64
2019-12-08T18:09:50.623+0100 I CONTROL [initandlisten] options: {}
2019-12-08T18:09:50.623+0100 I STORAGE [initandlisten] exception in initAndListen: NonExistentPath:
Data directory /data/db not found., terminating
2019-12-08T18:09:50.623+0100 I NETWORK [initandlisten] shutdown: going to close listening sockets...
2019-12-08T18:09:50.623+0100 I NETWORK [initandlisten] removing socket file: /tmp/mongodb-
27017.sock
2019-12-08T18:09:50.623+0100 I - [initandlisten] Stopping further Flow Control ticket
acquisitions.
2019-12-08T18:09:50.624+0100 I CONTROL [initandlisten] now exiting
2019-12-08T18:09:50.624+0100 I CONTROL [initandlisten] shutting down with code:100
System-info: Ubuntu 19.04
What can I do to fix this and make it work again without losing my data?
I solved it by going over the installation steps again: https://docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu/
This somehow solved it and now its working