# Increasing max\_file\_descriptors OSX

**URL:** <https://discuss.elastic.co/t/increasing-max-file-descriptors-osx/70482>\
**Category:** Elasticsearch\
**Created:** [January 3, 2017, 9:28pm UTC](https://discuss.elastic.co/t/increasing-max-file-descriptors-osx/70482 "2017-01-03T21:28:11Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![JonathanAaron](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jonathanaaron/32/24405_2.png) [@JonathanAaron](https://discuss.elastic.co/u/JonathanAaron)\
**Post date:** [January 3, 2017, 9:28pm UTC](https://discuss.elastic.co/t/increasing-max-file-descriptors-osx/70482/1 "2017-01-03T21:28:11Z")

</div>

[Solved] [2.4.3] I've set ulimit to 65000, but it keeps on showing up as 10240 when elasticsearch starts up. Is elasticsearch showing the valid max\_file\_descriptors?

Thanks

edit:  
I took @jasontedor advise from below. I set ulimit in bash\_profile or bashrc or zshrc. I started ES with this command. `ES_JAVA_OPTS="-XX:-MaxFDLimit" ./bin/elasticsearch` worked like magic.

---

<div class="post-metadata">

**Author:** ![jasontedor](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jasontedor/32/66992_2.png) [@jasontedor](https://discuss.elastic.co/u/jasontedor)\
**Post date:** [January 4, 2017, 2:31am UTC](https://discuss.elastic.co/t/increasing-max-file-descriptors-osx/70482/2 "2017-01-04T02:31:41Z")

</div>

This situation is _very_ complicated. 🙂

To get you running quickly:

- add the following content to `/etc/sysctl.conf` (create this file if it does not exist):

```auto
kern.maxfiles=65536
kern.maxfilesperproc=65536

```

- restart
- set `ulimit -n 65536`
- start the Elasticsearch process with the JVM option `-XX:-MaxFDLimit` (e.g., use `ES_JAVA_OPTS=-XX:-MaxFDLimit`)
- verify the file descriptors are correct by sending a request to `/_nodes/stats/process?pretty=1`

I've written up why this is such a headache previously: [https://github.com/elastic/elasticsearch/issues/16813#issuecomment-189541620](https://github.com/elastic/elasticsearch/issues/16813#issuecomment-189541620)

---

<div class="post-metadata">

**Author:** ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)\
**Post date:** [January 4, 2017, 9:51am UTC](https://discuss.elastic.co/t/increasing-max-file-descriptors-osx/70482/3 "2017-01-04T09:51:10Z")

</div>

Set the line

```auto
limit maxfiles 65536 65536

```

in `/etc/launchd.conf` and restart your Mac.

---

<div class="post-metadata">

**Author:** ![jasontedor](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jasontedor/32/66992_2.png) [@jasontedor](https://discuss.elastic.co/u/jasontedor)\
**Post date:** [January 4, 2017, 3:16pm UTC](https://discuss.elastic.co/t/increasing-max-file-descriptors-osx/70482/4 "2017-01-04T15:16:59Z")

</div>

This does not work since at least Yosemite, maybe sooner. If you want to go the `launchd` route, you have to create `/Library/LaunchDaemons/limit.maxfiles.plist` with the following content:

```auto
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
  <plist version="1.0">
    <dict>
      <key>Label</key>
        <string>limit.maxfiles</string>
      <key>ProgramArguments</key>
        <array>
          <string>launchctl</string>
          <string>limit</string>
          <string>maxfiles</string>
          <string>65536</string>
          <string>65536</string>
        </array>
      <key>RunAtLoad</key>
        <true/>
      <key>ServiceIPC</key>
        <false/>
    </dict>
  </plist>

```

This still requires a restart, and it still requires starting the JVM with `-XX:-MaxFDLimit`.

---

<div class="post-metadata">

**Author:** ![JonathanAaron](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jonathanaaron/32/24405_2.png) [@JonathanAaron](https://discuss.elastic.co/u/JonathanAaron)\
**Post date:** [January 4, 2017, 3:28pm UTC](https://discuss.elastic.co/t/increasing-max-file-descriptors-osx/70482/5 "2017-01-04T15:28:33Z")

</div>

What's funny is that my max file descriptors when from 10240 to 4864, lol. It did change.

---

<div class="post-metadata">

**Author:** ![JonathanAaron](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jonathanaaron/32/24405_2.png) [@JonathanAaron](https://discuss.elastic.co/u/JonathanAaron)\
**Post date:** [January 4, 2017, 4:10pm UTC](https://discuss.elastic.co/t/increasing-max-file-descriptors-osx/70482/6 "2017-01-04T16:10:01Z")

</div>

edit: This is working for me now! I put the ulimit -n 65536 in my .bash\_profile an everything started working. Thanks!

Yeah I reviewed everything I did that you suggested....for some reason my max\_file\_discriptors when down. I started ES with `ES_JAVA_OPTS="-XX:-MaxFDLimit" ./bin/elasticsearch`

Was that right?

```
{
  "cluster_name": "elasticsearch",
  "nodes": {
    "0ZpLUqNERb-V_-_izVkhsA": {
      "timestamp": 1483546091076,
      "name": "Mister X",
      "transport_address": "127.0.0.1:9300",
      "host": "127.0.0.1",
      "ip": [
        "127.0.0.1:9300",
        "NONE"
      ],
      "process": {
        "timestamp": 1483546091076,
        "open_file_descriptors": 273,
        "max_file_descriptors": 4864,
        "cpu": {
          "percent": 3,
          "total_in_millis": 8060
        },
        "mem": {
          "total_virtual_in_bytes": 5321494528
        }
      }
    }
  }
}
```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [February 1, 2017, 4:10pm UTC](https://discuss.elastic.co/t/increasing-max-file-descriptors-osx/70482/7 "2017-02-01T16:10:03Z")

</div>

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