I have the issue with 'Error setting up listener","attr":{"error":{"code":9001,"codeName":"SocketException","errmsg":"Permission denied"

I ran mongodb and failed with below Error.I don’t know how to solve it.Pls kindly help.

molly@xxxx:/etc$ mongod --dbpath /var/lib/mongodb
{"t":{"$date":"2022-08-05T23:29:53.768+08:00"},"s":"I",  "c":"CONTROL",  "id":23285,   "ctx":"main","msg":"Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'"}
{"t":{"$date":"2022-08-05T23:29:53.769+08:00"},"s":"W",  "c":"ASIO",     "id":22601,   "ctx":"main","msg":"No TransportLayer configured during NetworkInterface startup"}
{"t":{"$date":"2022-08-05T23:29:53.770+08:00"},"s":"I",  "c":"NETWORK",  "id":4648601, "ctx":"main","msg":"Implicit TCP FastOpen unavailable. If TCP FastOpen is required, set tcpFastOpenServer, tcpFastOpenClient, and tcpFastOpenQueueSize."}
{"t":{"$date":"2022-08-05T23:29:53.770+08:00"},"s":"I",  "c":"STORAGE",  "id":4615611, "ctx":"initandlisten","msg":"MongoDB starting","attr":{"pid":6319,"port":27017,"dbPath":"/var/lib/mongodb","architecture":"64-bit","host":"Francisco"}}
{"t":{"$date":"2022-08-05T23:29:53.770+08:00"},"s":"I",  "c":"CONTROL",  "id":23403,   "ctx":"initandlisten","msg":"Build Info","attr":{"buildInfo":{"version":"4.4.15","gitVersion":"bc17cf2c788c5dda2801a090ea79da5ff7d5fac9","openSSLVersion":"OpenSSL 1.1.1  11 Sep 2018","modules":[],"allocator":"tcmalloc","environment":{"distmod":"ubuntu1804","distarch":"x86_64","target_arch":"x86_64"}}}}
{"t":{"$date":"2022-08-05T23:29:53.770+08:00"},"s":"I",  "c":"CONTROL",  "id":51765,   "ctx":"initandlisten","msg":"Operating System","attr":{"os":{"name":"Ubuntu","version":"18.04"}}}
{"t":{"$date":"2022-08-05T23:29:53.770+08:00"},"s":"I",  "c":"CONTROL",  "id":21951,   "ctx":"initandlisten","msg":"Options set by command line","attr":{"options":{"storage":{"dbPath":"/var/lib/mongodb"}}}}
{"t":{"$date":"2022-08-05T23:29:53.770+08:00"},"s":"E",  "c":"STORAGE",  "id":20568,   "ctx":"initandlisten","msg":"Error setting up listener","attr":{"error":{"code":9001,"codeName":"SocketException","errmsg":"Permission denied"}}}
{"t":{"$date":"2022-08-05T23:29:53.770+08:00"},"s":"I",  "c":"REPL",     "id":4784900, "ctx":"initandlisten","msg":"Stepping down the ReplicationCoordinator for shutdown","attr":{"waitTimeMillis":10000}}
{"t":{"$date":"2022-08-05T23:29:53.771+08:00"},"s":"I",  "c":"COMMAND",  "id":4784901, "ctx":"initandlisten","msg":"Shutting down the MirrorMaestro"}
{"t":{"$date":"2022-08-05T23:29:53.771+08:00"},"s":"I",  "c":"SHARDING", "id":4784902, "ctx":"initandlisten","msg":"Shutting down the WaitForMajorityService"}
{"t":{"$date":"2022-08-05T23:29:53.771+08:00"},"s":"I",  "c":"NETWORK",  "id":4784905, "ctx":"initandlisten","msg":"Shutting down the global connection pool"}
{"t":{"$date":"2022-08-05T23:29:53.771+08:00"},"s":"I",  "c":"NETWORK",  "id":4784918, "ctx":"initandlisten","msg":"Shutting down the ReplicaSetMonitor"}
{"t":{"$date":"2022-08-05T23:29:53.771+08:00"},"s":"I",  "c":"SHARDING", "id":4784921, "ctx":"initandlisten","msg":"Shutting down the MigrationUtilExecutor"}
{"t":{"$date":"2022-08-05T23:29:53.771+08:00"},"s":"I",  "c":"CONTROL",  "id":4784925, "ctx":"initandlisten","msg":"Shutting down free monitoring"}
{"t":{"$date":"2022-08-05T23:29:53.771+08:00"},"s":"I",  "c":"STORAGE",  "id":4784927, "ctx":"initandlisten","msg":"Shutting down the HealthLog"}
{"t":{"$date":"2022-08-05T23:29:53.771+08:00"},"s":"I",  "c":"STORAGE",  "id":4784929, "ctx":"initandlisten","msg":"Acquiring the global lock for shutdown"}
{"t":{"$date":"2022-08-05T23:29:53.771+08:00"},"s":"I",  "c":"-",        "id":4784931, "ctx":"initandlisten","msg":"Dropping the scope cache for shutdown"}
{"t":{"$date":"2022-08-05T23:29:53.771+08:00"},"s":"I",  "c":"FTDC",     "id":4784926, "ctx":"initandlisten","msg":"Shutting down full-time data capture"}
{"t":{"$date":"2022-08-05T23:29:53.771+08:00"},"s":"I",  "c":"CONTROL",  "id":20565,   "ctx":"initandlisten","msg":"Now exiting"}
{"t":{"$date":"2022-08-05T23:29:53.771+08:00"},"s":"I",  "c":"CONTROL",  "id":23138,   "ctx":"initandlisten","msg":"Shutting down","attr":{"exitCode":48}}

:wave:

Hi @Molly_She and welcome to the MongoDB community.

Can you please supply to following information so that we might be able to help you?

  • What operating system are you running on?
  • How was MongoDB installed?
  • Is this the first time you’ve tried starting the mongod process, or has it been working in the past and is only now starting to fail?

Hi Doug:
Thanks for replying me. I ran this on Ubuntu18.04 as I tried to set up a Yapi server. It asked me to setup MongoDb.
I followed below guide to install the Mongodb. The only difference is I used 4.4 version for Mongodb installation.

( Install MongoDB part including ’ Add the init script to start MongoDB as a service’ part)
This is the first time I ran MongoDB on my machine as I just installed it.

Thanks for the info Molly!

I don’t have a Windows box to test things out under WSL, but I’m wondering what the results of running ls -alh /tmp return for you (post the complete output)? Do you see a file with a name of mongodb-27017.sock?

This file ‘/tmp/mongodb-27017.sock’ can be seen. And when I met this ,I removed it and restart mongodb.

My colleague give me below solution:
1.ps -eaf | grep mongodb 2.service mongodb stop 3.check the pid listed again. 4.kill the pid. 5.Then start db by using sudo mongod --dbpath /var/lib/mongodb instead of service mongodb start.


Then the issue solved.

I’m glad you got things resolved Molly!