connect ECONNREFUSED 127.0.0.1:52885, connect ECONNREFUSED ::1:52885

I use atlas deployment setup to build a new local database to create search index, port is 52885.
But I face the problem connect ECONNREFUSED 127.0.0.1:52885, connect ECONNREFUSED ::1:52885. and also default port 27017 can’t connect too.
I follow some guide to fix the problem: sudo brew services start mongodb-community

It fix 27017 port but 52885 still face the problem.

Could tell me how I fix the problem?
when I use mongod --port 52885, I get the following :

{“t”:{“$date”:“2024-08-26T13:29:01.545+02:00”},“s”:“I”, “c”:“CONTROL”, “id”:23285, “ctx”:“thread1”,“msg”:“Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols ‘none’”}
{“t”:{“$date”:“2024-08-26T13:29:01.545+02:00”},“s”:“I”, “c”:“NETWORK”, “id”:4915701, “ctx”:“thread1”,“msg”:“Initialized wire specification”,“attr”:{“spec”:{“incomingExternalClient”:{“minWireVersion”:0,“maxWireVersion”:21},“incomingInternalClient”:{“minWireVersion”:0,“maxWireVersion”:21},“outgoing”:{“minWireVersion”:6,“maxWireVersion”:21},“isInternalClient”:true}}}
{“t”:{“$date”:“2024-08-26T13:29:01.561+02:00”},“s”:“I”, “c”:“NETWORK”, “id”:4648602, “ctx”:“thread1”,“msg”:“Implicit TCP FastOpen in use.”}
{“t”:{“$date”:“2024-08-26T13:29:01.565+02:00”},“s”:“I”, “c”:“REPL”, “id”:5123008, “ctx”:“thread1”,“msg”:“Successfully registered PrimaryOnlyService”,“attr”:{“service”:“TenantMigrationDonorService”,“namespace”:“config.tenantMigrationDonors”}}
{“t”:{“$date”:“2024-08-26T13:29:01.565+02:00”},“s”:“I”, “c”:“REPL”, “id”:5123008, “ctx”:“thread1”,“msg”:“Successfully registered PrimaryOnlyService”,“attr”:{“service”:“TenantMigrationRecipientService”,“namespace”:“config.tenantMigrationRecipients”}}
{“t”:{“$date”:“2024-08-26T13:29:01.565+02:00”},“s”:“I”, “c”:“CONTROL”, “id”:5945603, “ctx”:“thread1”,“msg”:“Multi threading initialized”}
{“t”:{“$date”:“2024-08-26T13:29:01.565+02:00”},“s”:“I”, “c”:“TENANT_M”, “id”:7091600, “ctx”:“thread1”,“msg”:“Starting TenantMigrationAccessBlockerRegistry”}
{“t”:{“$date”:“2024-08-26T13:29:01.565+02:00”},“s”:“I”, “c”:“CONTROL”, “id”:4615611, “ctx”:“initandlisten”,“msg”:“MongoDB starting”,“attr”:{“pid”:14218,“port”:52885,“dbPath”:“/data/db”,“architecture”:“64-bit”,“host”:“ruidan.local”}}
{“t”:{“$date”:“2024-08-26T13:29:01.565+02:00”},“s”:“I”, “c”:“CONTROL”, “id”:23403, “ctx”:“initandlisten”,“msg”:“Build Info”,“attr”:{“buildInfo”:{“version”:“7.0.14”,“gitVersion”:“ce59cfc6a3c5e5c067dca0d30697edd68d4f5188”,“modules”:,“allocator”:“system”,“environment”:{“distarch”:“aarch64”,“target_arch”:“aarch64”}}}}
{“t”:{“$date”:“2024-08-26T13:29:01.565+02:00”},“s”:“I”, “c”:“CONTROL”, “id”:51765, “ctx”:“initandlisten”,“msg”:“Operating System”,“attr”:{“os”:{“name”:“Mac OS X”,“version”:“23.4.0”}}}
{“t”:{“$date”:“2024-08-26T13:29:01.565+02:00”},“s”:“I”, “c”:“CONTROL”, “id”:21951, “ctx”:“initandlisten”,“msg”:“Options set by command line”,“attr”:{“options”:{“net”:{“port”:52885}}}}
{“t”:{“$date”:“2024-08-26T13:29:01.567+02:00”},“s”:“I”, “c”:“NETWORK”, “id”:5693100, “ctx”:“initandlisten”,“msg”:“Asio socket.set_option failed with std::system_error”,“attr”:{“note”:“acceptor TCP fast open”,“option”:{“level”:6,“name”:261,“data”:“00 04 00 00”},“error”:{“what”:“set_option: Invalid argument”,“message”:“Invalid argument”,“category”:“asio.system”,“value”:22}}}
{“t”:{“$date”:“2024-08-26T13:29:01.568+02:00”},“s”:“E”, “c”:“CONTROL”, “id”:20557, “ctx”:“initandlisten”,“msg”:“DBException in initAndListen, terminating”,“attr”:{“error”:“NonExistentPath: Data directory /data/db not found. Create the missing directory or specify another path using (1) the --dbpath command line option, or (2) by adding the ‘storage.dbPath’ option in the configuration file.”}}
{“t”:{“$date”:“2024-08-26T13:29:01.568+02:00”},“s”:“I”, “c”:“REPL”, “id”:4784900, “ctx”:“initandlisten”,“msg”:“Stepping down the ReplicationCoordinator for shutdown”,“attr”:{“waitTimeMillis”:15000}}
{“t”:{“$date”:“2024-08-26T13:29:01.568+02:00”},“s”:“I”, “c”:“REPL”, “id”:4794602, “ctx”:“initandlisten”,“msg”:“Attempting to enter quiesce mode”}
{“t”:{“$date”:“2024-08-26T13:29:01.568+02:00”},“s”:“I”, “c”:“-”, “id”:6371601, “ctx”:“initandlisten”,“msg”:“Shutting down the FLE Crud thread pool”}
{“t”:{“$date”:“2024-08-26T13:29:01.568+02:00”},“s”:“I”, “c”:“COMMAND”, “id”:4784901, “ctx”:“initandlisten”,“msg”:“Shutting down the MirrorMaestro”}
{“t”:{“$date”:“2024-08-26T13:29:01.568+02:00”},“s”:“I”, “c”:“SHARDING”, “id”:4784902, “ctx”:“initandlisten”,“msg”:“Shutting down the WaitForMajorityService”}
{“t”:{“$date”:“2024-08-26T13:29:01.568+02:00”},“s”:“I”, “c”:“NETWORK”, “id”:20562, “ctx”:“initandlisten”,“msg”:“Shutdown: going to close listening sockets”}
{“t”:{“$date”:“2024-08-26T13:29:01.568+02:00”},“s”:“I”, “c”:“NETWORK”, “id”:4784905, “ctx”:“initandlisten”,“msg”:“Shutting down the global connection pool”}
{“t”:{“$date”:“2024-08-26T13:29:01.568+02:00”},“s”:“I”, “c”:“CONTROL”, “id”:4784906, “ctx”:“initandlisten”,“msg”:“Shutting down the FlowControlTicketholder”}
{“t”:{“$date”:“2024-08-26T13:29:01.568+02:00”},“s”:“I”, “c”:“-”, “id”:20520, “ctx”:“initandlisten”,“msg”:“Stopping further Flow Control ticket acquisitions.”}
{“t”:{“$date”:“2024-08-26T13:29:01.568+02:00”},“s”:“I”, “c”:“NETWORK”, “id”:4784918, “ctx”:“initandlisten”,“msg”:“Shutting down the ReplicaSetMonitor”}
{“t”:{“$date”:“2024-08-26T13:29:01.568+02:00”},“s”:“I”, “c”:“SHARDING”, “id”:4784921, “ctx”:“initandlisten”,“msg”:“Shutting down the MigrationUtilExecutor”}
{“t”:{“$date”:“2024-08-26T13:29:01.568+02:00”},“s”:“I”, “c”:“ASIO”, “id”:22582, “ctx”:“MigrationUtil-TaskExecutor”,“msg”:“Killing all outstanding egress activity.”}
{“t”:{“$date”:“2024-08-26T13:29:01.568+02:00”},“s”:“I”, “c”:“COMMAND”, “id”:4784923, “ctx”:“initandlisten”,“msg”:“Shutting down the ServiceEntryPoint”}
{“t”:{“$date”:“2024-08-26T13:29:01.568+02:00”},“s”:“I”, “c”:“CONTROL”, “id”:4784928, “ctx”:“initandlisten”,“msg”:“Shutting down the TTL monitor”}
{“t”:{“$date”:“2024-08-26T13:29:01.568+02:00”},“s”:“I”, “c”:“CONTROL”, “id”:6278511, “ctx”:“initandlisten”,“msg”:“Shutting down the Change Stream Expired Pre-images Remover”}
{“t”:{“$date”:“2024-08-26T13:29:01.568+02:00”},“s”:“I”, “c”:“CONTROL”, “id”:4784929, “ctx”:“initandlisten”,“msg”:“Acquiring the global lock for shutdown”}
{“t”:{“$date”:“2024-08-26T13:29:01.568+02:00”},“s”:“I”, “c”:“-”, “id”:4784931, “ctx”:“initandlisten”,“msg”:“Dropping the scope cache for shutdown”}
{“t”:{“$date”:“2024-08-26T13:29:01.568+02:00”},“s”:“I”, “c”:“CONTROL”, “id”:20565, “ctx”:“initandlisten”,“msg”:“Now exiting”}
{“t”:{“$date”:“2024-08-26T13:29:01.568+02:00”},“s”:“I”, “c”:“CONTROL”, “id”:8423404, “ctx”:“initandlisten”,“msg”:“mongod shutdown complete”,“attr”:{“Summary of time elapsed”:{“Statistics”:{“Enter terminal shutdown”:“0 ms”,“Step down the replication coordinator for shutdown”:“0 ms”,“Time spent in quiesce mode”:“0 ms”,“Shut down FLE Crud subsystem”:“0 ms”,“Shut down MirrorMaestro”:“0 ms”,“Shut down WaitForMajorityService”:“0 ms”,“Shut down the transport layer”:“0 ms”,“Shut down the global connection pool”:“0 ms”,“Shut down the flow control ticket holder”:“0 ms”,“Shut down the replica set monitor”:“0 ms”,“Shut down the migration util executor”:“0 ms”,“Shut down the TTL monitor”:“0 ms”,“Shut down expired pre-images and documents removers”:“0 ms”,“Wait for the oplog cap maintainer thread to stop”:“0 ms”,“Shut down full-time data capture”:“0 ms”,“shutdownTask total elapsed time”:“0 ms”}}}}
{“t”:{“$date”:“2024-08-26T13:29:01.568+02:00”},“s”:“I”, “c”:“CONTROL”, “id”:23138, “ctx”:“initandlisten”,“msg”:“Shutting down”,“attr”:{“exitCode”:100}}

Your dbpath dir is missing
If you do not specify dirpath mongod looks for default dir /data/db
Either create the missing directory or choose another dirpath where mongod can write as indicated in the error logs

could you tell me how to get the path of port 52885?

The following commands work fine for me:

  1. find mongdb.conf and find the storage path from mongb.conf
    dbPath: /opt/homebrew/var/mongodb

  2. open the folder Permissions
    sudo chown -R $(whoami) /opt/homebrew/var/mongodb

  3. mongod --port 52885 --dbpath /opt/homebrew/var/mongodb

It already gave you the path it is looking for
Create /data/db dir and you should be good to start your mongod on port 52885
There is a difference between two below commands
mongod --port 52885------------->this looks for default dir /data/db
mongod --port 52885 --dbpath xyz----->This uses whatever path you specify for xyz

Also do not use same path given in your config file when starting mongod on a different port
So the standard config file is used by your brew services start which brings up mongod on default port 27017

If you use same dbpath /opt/homebrew/var/mongodb for both manual and service you may overwrite files or it may throw error
Never use same dbpath for different mongods on the same machine

1 Like