M103 Ch1 Lab: Change the Default DB Path

Facing this error while using mongod in inbrowser IDE

MongoDB shell version v4.0.5
connecting to: mongodb://127.0.0.1:27017/?gssapiServiceName=mongodb
2021-02-16T10:20:20.012+0000 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:328:13
@(connect):1:6
exception: connect failed
bash-4.4# mongod
2021-02-16T10:20:25.104+0000 I CONTROL [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols ‘none’
2021-02-16T10:20:25.116+0000 I CONTROL [initandlisten] MongoDB starting : pid=346 port=27017 dbpath=/data/db 64-bit host=w4Zq5ix2HE2NTMXhyI
2021-02-16T10:20:25.116+0000 I CONTROL [initandlisten] db version v4.0.5
2021-02-16T10:20:25.116+0000 I CONTROL [initandlisten] git version: 3739429dd92b92d1b0ab120911a23d50bf03c412
2021-02-16T10:20:25.116+0000 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.1.1g 21 Apr 2020
2021-02-16T10:20:25.116+0000 I CONTROL [initandlisten] allocator: system
2021-02-16T10:20:25.116+0000 I CONTROL [initandlisten] modules: none
2021-02-16T10:20:25.116+0000 I CONTROL [initandlisten] build environment:
2021-02-16T10:20:25.116+0000 I CONTROL [initandlisten] distarch: x86_64
2021-02-16T10:20:25.116+0000 I CONTROL [initandlisten] target_arch: x86_64
2021-02-16T10:20:25.116+0000 I CONTROL [initandlisten] options: {}
2021-02-16T10:20:25.163+0000 I STORAGE [initandlisten] exception in initAndListen: NonExistentPath: Data directory /data/db not found., terminating
2021-02-16T10:20:25.163+0000 I NETWORK [initandlisten] shutdown: going to close listening sockets…
2021-02-16T10:20:25.163+0000 I NETWORK [initandlisten] removing socket file: /tmp/mongodb-27017.sock
2021-02-16T10:20:25.163+0000 I CONTROL [initandlisten] now exiting
2021-02-16T10:20:25.163+0000 I CONTROL [initandlisten] shutting down with code:100

You question is related to course M103 from MongoDB university. You will have better luck asking your question on the course specific thread from the university’s forum.

The above indicates that there is no server listening at this address and port number.

The above indicates that the data directory /data/db does not exists. It has to be created before starting mongod.

1 Like

[
Error: couldn’t connect to server 127.0.0.1:27017,
[/quote]

The above indicates that there is no server listening at this address and port number.

pls tell how to resolve it

You start an instance of mongod with the appropriate configuration. In this particular case, since 127.0.0.1 and 27017 are the default values, just running mongod will try to start a server that listen there. But that is not what they asked in the course. That is why

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.