I´m testing around with MongoDB and NodeJS. I´m stuck with the problem that I can create max 4899 connections to MongoDB. I´ve set the poolSize in the NodeJS Mongo driver to 40000. Also I´ve set the needed ulimits of the mongo server.

Does anyone have an idea why the mongo server refuses new connections as soon as 4899 are reached? The problem is definitely on th DB server side and not on client side.

I´m using the newest versions of all components (nodeJS V8, Mongo, Node mongo native driver)

limits configuration:

net.ipv4.ip_local_port_range = 1024 65000

mongodb         hard    nofile          1048576
mongodb         soft    nofile          1048576
mongodb         soft    nproc           1048576
mongodb         hard    nproc           1048576
mongodb         hard    stack           16384
mongodb         soft    stack           16384
mongodb         hard    memlock         unlimited
mongodb         soft    memlock         unlimited

# (file size)
# (cpu time)
# (virtual memory size)
# (open files)
# (processes/threads)

mongo serverstats:

        "current" : 4899,
        "available" : 395101,
        "totalCreated" : NumberLong(5279)
  • Possible duplicate of MongoDB high rps running into limits? Oct 20, 2017 at 3:24
  • Yes, the problem it´s self is a duplicate. But I did some more testing and could exclude some possible reasons. Due to that I´ve also changed the question which is now much more specific. Sorry, I´ve deleted the previous question now.
    – teldri
    Oct 20, 2017 at 7:17

1 Answer 1


Finally found the solution by myself:

in the systemd service configuration file /lib/systemd/system/mongodb.service set the following values to override the systemd tasklimit:

# (disable systemd tracking of number of tasks)

# (disable systemd tasklimit) possible values: infinity, a absolute number, or percentage of system wide limit
  • Teldri, you can also mark your answer as the accepted answer to take full credit for solving the issue :) Oct 20, 2017 at 14:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.