Asio socket.set_option failed with std::system_error - MongoDb 5.x

I had to restart my MacBook Pro for an iOS update and since then I can’t start MongoDb anymore (using Community version 4.4 via Homebrew). I’m trying to start run-rs which has run for years without problems, not it’s failing with this Asio socket.set_option error.

This is the log file:

run-rs --version=5.0.27 --dbpath /usr/local/var/mongodb --keep --shell
Skipping purge
Running ‘/usr/local/lib/node_modules/run-rs/5.0.27/mongod’ [ 27017, 27018, 27019 ]
Restarting replica set…
Error: failed to start mongod with options [
‘–port=27017’,
‘–dbpath=/usr/local/var/mongodb/27017’,
‘–bind_ip=localhost’,
‘–replSet=rs’
]
{“t”:{“$date”:“2024-08-16T14:05:45.406+08:00”},“s”:“I”, “c”:“NETWORK”, “id”:4915701, “ctx”:“-”,“msg”:“Initialized wire specification”,“attr”:{“spec”:{“incomingExternalClient”:{“minWireVersion”:0,“maxWireVersion”:13},“incomingInternalClient”:{“minWireVersion”:0,“maxWireVersion”:13},“outgoing”:{“minWireVersion”:0,“maxWireVersion”:13},“isInternalClient”:true}}}
{“t”:{“$date”:“2024-08-16T14:05:45.409+08:00”},“s”:“I”, “c”:“CONTROL”, “id”:23285, “ctx”:“-”,“msg”:“Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols ‘none’”}
{“t”:{“$date”:“2024-08-16T14:05:45.409+08:00”},“s”:“W”, “c”:“ASIO”, “id”:22601, “ctx”:“thread1”,“msg”:“No TransportLayer configured during NetworkInterface startup”}
{“t”:{“$date”:“2024-08-16T14:05:45.410+08:00”},“s”:“I”, “c”:“NETWORK”, “id”:4648602, “ctx”:“thread1”,“msg”:“Implicit TCP FastOpen in use.”}
{“t”:{“$date”:“2024-08-16T14:05:45.412+08:00”},“s”:“W”, “c”:“ASIO”, “id”:22601, “ctx”:“thread1”,“msg”:“No TransportLayer configured during NetworkInterface startup”}
{“t”:{“$date”:“2024-08-16T14:05:45.413+08:00”},“s”:“W”, “c”:“ASIO”, “id”:22601, “ctx”:“thread1”,“msg”:“No TransportLayer configured during NetworkInterface startup”}
{“t”:{“$date”:“2024-08-16T14:05:45.413+08:00”},“s”:“I”, “c”:“REPL”, “id”:5123008, “ctx”:“thread1”,“msg”:“Successfully registered PrimaryOnlyService”,“attr”:{“service”:“TenantMigrationDonorService”,“ns”:“config.tenantMigrationDonors”}}
{“t”:{“$date”:“2024-08-16T14:05:45.413+08:00”},“s”:“I”, “c”:“REPL”, “id”:5123008, “ctx”:“thread1”,“msg”:“Successfully registered PrimaryOnlyService”,“attr”:{“service”:“TenantMigrationRecipientService”,“ns”:“config.tenantMigrationRecipients”}}
{“t”:{“$date”:“2024-08-16T14:05:45.414+08:00”},“s”:“I”, “c”:“CONTROL”, “id”:5945603, “ctx”:“thread1”,“msg”:“Multi threading initialized”}
{“t”:{“$date”:“2024-08-16T14:05:45.414+08:00”},“s”:“I”, “c”:“CONTROL”, “id”:4615611, “ctx”:“initandlisten”,“msg”:“MongoDB starting”,“attr”:{“pid”:80751,“port”:27017,“dbPath”:“/usr/local/var/mongodb/27017”,“architecture”:“64-bit”,“host”:“macbook-pro-2.lan”}}
{“t”:{“$date”:“2024-08-16T14:05:45.414+08:00”},“s”:“I”, “c”:“CONTROL”, “id”:23403, “ctx”:“initandlisten”,“msg”:“Build Info”,“attr”:{“buildInfo”:{“version”:“5.0.27”,“gitVersion”:“49571988f1fea870e803f71a3ef8417173f3fbb1”,“modules”:,“allocator”:“system”,“environment”:{“distarch”:“x86_64”,“target_arch”:“x86_64”}}}}
{“t”:{“$date”:“2024-08-16T14:05:45.414+08:00”},“s”:“I”, “c”:“CONTROL”, “id”:51765, “ctx”:“initandlisten”,“msg”:“Operating System”,“attr”:{“os”:{“name”:“Mac OS X”,“version”:“23.6.0”}}}
{“t”:{“$date”:“2024-08-16T14:05:45.414+08:00”},“s”:“I”, “c”:“CONTROL”, “id”:21951, “ctx”:“initandlisten”,“msg”:“Options set by command line”,“attr”:{“options”:{“net”:{“bindIp”:“localhost”,“port”:27017},“replication”:{“replSet”:“rs”},“storage”:{“dbPath”:“/usr/local/var/mongodb/27017”}}}}
{“t”:{“$date”:“2024-08-16T14:05:45.417+08: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-16T14:05:45.418+08:00”},“s”:“E”, “c”:“CONTROL”, “id”:20568, “ctx”:“initandlisten”,“msg”:“Error setting up listener”,“attr”:{“error”:{“code”:9001,“codeName”:“SocketException”,“errmsg”:“Address already in use”}}}
{“t”:{“$date”:“2024-08-16T14:05:45.418+08:00”},“s”:“I”, “c”:“REPL”, “id”:4784900, “ctx”:“initandlisten”,“msg”:“Stepping down the ReplicationCoordinator for shutdown”,“attr”:{“waitTimeMillis”:15000}}
{“t”:{“$date”:“2024-08-16T14:05:45.421+08:00”},“s”:“I”, “c”:“COMMAND”, “id”:4784901, “ctx”:“initandlisten”,“msg”:“Shutting down the MirrorMaestro”}
{“t”:{“$date”:“2024-08-16T14:05:45.421+08:00”},“s”:“I”, “c”:“SHARDING”, “id”:4784902, “ctx”:“initandlisten”,“msg”:“Shutting down the WaitForMajorityService”}
{“t”:{“$date”:“2024-08-16T14:05:45.421+08:00”},“s”:“I”, “c”:“NETWORK”, “id”:4784905, “ctx”:“initandlisten”,“msg”:“Shutting down the global connection pool”}
{“t”:{“$date”:“2024-08-16T14:05:45.421+08:00”},“s”:“I”, “c”:“REPL”, “id”:4784907, “ctx”:“initandlisten”,“msg”:“Shutting down the replica set node executor”}
{“t”:{“$date”:“2024-08-16T14:05:45.421+08:00”},“s”:“I”, “c”:“NETWORK”, “id”:4784918, “ctx”:“initandlisten”,“msg”:“Shutting down the ReplicaSetMonitor”}
{“t”:{“$date”:“2024-08-16T14:05:45.421+08:00”},“s”:“I”, “c”:“SHARDING”, “id”:4784921, “ctx”:“initandlisten”,“msg”:“Shutting down the MigrationUtilExecutor”}
{“t”:{“$date”:“2024-08-16T14:05:45.421+08:00”},“s”:“I”, “c”:“ASIO”, “id”:22582, “ctx”:“MigrationUtil-TaskExecutor”,“msg”:“Killing all outstanding egress activity.”}
{“t”:{“$date”:“2024-08-16T14:05:45.421+08:00”},“s”:“I”, “c”:“COMMAND”, “id”:4784923, “ctx”:“initandlisten”,“msg”:“Shutting down the ServiceEntryPoint”}
{“t”:{“$date”:“2024-08-16T14:05:45.421+08:00”},“s”:“I”, “c”:“CONTROL”, “id”:4784928, “ctx”:“initandlisten”,“msg”:“Shutting down the TTL monitor”}
{“t”:{“$date”:“2024-08-16T14:05:45.421+08:00”},“s”:“I”, “c”:“CONTROL”, “id”:4784929, “ctx”:“initandlisten”,“msg”:“Acquiring the global lock for shutdown”}
{“t”:{“$date”:“2024-08-16T14:05:45.421+08:00”},“s”:“I”, “c”:“-”, “id”:4784931, “ctx”:“initandlisten”,“msg”:“Dropping the scope cache for shutdown”}
{“t”:{“$date”:“2024-08-16T14:05:45.421+08:00”},“s”:“I”, “c”:“FTDC”, “id”:4784926, “ctx”:“initandlisten”,“msg”:“Shutting down full-time data capture”}
{“t”:{“$date”:“2024-08-16T14:05:45.421+08:00”},“s”:“I”, “c”:“CONTROL”, “id”:20565, “ctx”:“initandlisten”,“msg”:“Now exiting”}
{“t”:{“$date”:“2024-08-16T14:05:45.422+08:00”},“s”:“I”, “c”:“CONTROL”, “id”:23138, “ctx”:“initandlisten”,“msg”:“Shutting down”,“attr”:{“exitCode”:48}}

at ChildProcess.<anonymous> (/usr/local/lib/node_modules/run-rs/src/topologyManagerPatch.js:152:13)
at ChildProcess.emit (node:events:520:28)
at maybeClose (node:internal/child_process:1105:16)
at ChildProcess._handle.onexit (node:internal/child_process:305:5)

I’m aware of this topic: MongoDB 5.0 Fails to run in Mac OS with Homebrew Error 25600 (Asio Socket failing)

however this same folder has worked without any problems.

Any help is appreciated, thanks!

This was the solution that worked for me: mongodb - Get this error to start the mongo db : Failed to set up listener: SocketException: Address already in use - Stack Overflow

  • sudo lsof -iTCP -sTCP:LISTEN -n -P
  • sudo kill <mongo_command_pid>

After that I could run it without a problem. It seems that the listener was the problem

1 Like

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