WSL: Can't raise "open files" ulimit

Please use the following bug reporting template to help produce actionable and reproducible issues. Please try to ensure that the reproduction is minimal so that the team can go through more bugs!

  • A brief description

The “open files” ulimit can’t currently be increased.

I know of two use cases for setting this ulimit:

  • NodeJS (and therefore lots of common NodeJS tools – npm, grunt, etc) has a common design idiom of “process all of these files”, whose default implementation is to open all of the files asynchronously and process them as the OS gets around to reading them. “All of the files” can be quite a lot 😃 So NodeJS users often have to either bump this limit, or modify their own tools to use graceful-js. Modifying existing tools can be hard, so simply bumping the limit is sometimes the preferred workaround. (I think this is the real issue behind #1679 )

  • Some databases (I personally know that Vertica does this; I think I recall hearing that MySQL can do the same?) can, in certain situations, open very large numbers of file descriptors. The objective is typically to have some clever effect on query performance. Decreasing the number of available file descriptors sacrifices query performance and/or causes errors.

  • Expected results

$ ulimit -n 65536
$

And the actual limit is updated

  • Actual results (with terminal output if applicable)
$ ulimit -n 65536
bash: ulimit: open files: cannot modify limit: Operation not permitted
  • Your Windows build number

15031

  • Steps / All commands required to reproduce the error from a brand new installation

See above

  • Strace of the failing command

If you really want an strace of bash -c 'ulimit -n 65536', I can post one. It’s going to be long, though, and I bet y’all already know what the important part is 😃

  • Required packages and commands to install

None – bash builtin.

See our contributing instructions for assistance.

About this issue

  • Original URL
  • State: closed
  • Created 10 years ago
  • Reactions: 9
  • Comments: 32 (4 by maintainers)

Most upvoted comments

Bumping this, it makes Ubuntu on windows unusable for professional developer use with node and as a consequence with pretty much anything that uses node to comple large numbers of assets.

Can we get a little attention, or at least have this scheduled?

Thanks.

Today, with the lates WSL2 - ubuntu, I can not change ulimit -n for common user. I can change the value for root. How to deal with this?

I was running into this error with WSL2 also. After changing everything outlined through this issue the limits for ulimit wouldn’t be raised and wouldn’t let me modify the values past the limits, but when checking the rights for the user I was running my command as: sudo su username --shell /bin/bash --command "ulimit -n" The ulimit would return the raised value. I then logged into myself from myself su username --shell /bin/bash and I was able to raise the ulimit values as expected, but only for that session. This makes me think that the initial WSL shell is restricted in some way.

I too am having this issue with ulimit in WSL 2… and vm.max_map_count isn’t available in WSL 1, so it makes running Elasticsearch pretty much impossible in ANY WSL distro 😦 Wish someone from MS would address this… maybe give us an answer here.

I get only one chance to increase the limit ? When I try to increase limit first time, it allows any value (upto 65536). But if I decrease the limit to a smaller value, it cannot increase it to anything above it. Is this expected behaviour ? I am using build 17134.

$ ulimit -n
1024
$ ulimit -n 65536
$ ulimit -n 65535
$ ulimit -n 65536
bash: ulimit: open files: cannot modify limit: Invalid argument
$ ulimit -n 10000
$ ulimit -n 10001
bash: ulimit: open files: cannot modify limit: Invalid argument
$ ulimit -n 7000
$ ulimit -n 7001
bash: ulimit: open files: cannot modify limit: Invalid argument

su username

I edited /etc/security/limits.conf and then used the above. Great workaround. Thanks @BerserkerGaruk !

@benhillis I have updated to the build of 16257, the “ulimit -n” can be changed. However, as an atmospheric scientist, i want to know that if the “ulimit -s” to be changed to unlimited, as we want to use the wsl on the workstation. Now the stack size is static 8192K, too limited for modeling.

Support was added in 16257.

It’s crazy that this is somehow marked closed and fixed. The sudo su workaround works for me, but that really shouldn’t be necessary. Needing to disable sudo passwords is a security risk.

@atomicthumbs - taking a look at this now.