Problems connecting to the server

I tried to connect mongodb.
First of all, I reconnect with the line:

 mongod --port 27000

After that I got an exception.

2022-05-11T19:57:30.464+0000 I CONTROL  [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
2022-05-11T19:57:30.471+0000 I CONTROL  [initandlisten] MongoDB starting : pid=419 port=27000 dbpath=/data/db 64-bit host=SLplqjHtmbsmfrPWjF
2022-05-11T19:57:30.471+0000 I CONTROL  [initandlisten] db version v4.0.5
2022-05-11T19:57:30.471+0000 I CONTROL  [initandlisten] git version: 3739429dd92b92d1b0ab120911a23d50bf03c412
2022-05-11T19:57:30.471+0000 I CONTROL  [initandlisten] OpenSSL version: OpenSSL 1.1.1g  21 Apr 2020
2022-05-11T19:57:30.471+0000 I CONTROL  [initandlisten] allocator: system
2022-05-11T19:57:30.471+0000 I CONTROL  [initandlisten] modules: none
2022-05-11T19:57:30.471+0000 I CONTROL  [initandlisten] build environment:
2022-05-11T19:57:30.471+0000 I CONTROL  [initandlisten]     distarch: x86_64
2022-05-11T19:57:30.471+0000 I CONTROL  [initandlisten]     target_arch: x86_64
2022-05-11T19:57:30.471+0000 I CONTROL  [initandlisten] options: { net: { port: 27000 } }
2022-05-11T19:57:30.471+0000 E STORAGE  [initandlisten] Failed to set up listener: SocketException: Address in use
2022-05-11T19:57:30.471+0000 I CONTROL  [initandlisten] now exiting
2022-05-11T19:57:30.471+0000 I CONTROL  [initandlisten] shutting down with code:48
MongoDB shell version v4.0.5
connecting to: mongodb://127.0.0.1:27017/?gssapiServiceName=mongodb
2022-05-11T19:54:51.596+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

This is not how you connect. This is how you start mongod. And another mongod is running at the same port because you got:

The command you used and that produce

is also wrong. The server is listening on port 27000 you have to specify 27000 as the port number.

1 Like

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