Last Updated: February 25, 2016
·
756
· dsliek

Exceeding Maximum Open Files On OSX With Karma

The Problem: Default Open File Limit Exceeded

In OSX, the maximum number of open file descriptors is set to 256 by default. If you meet this limit while running specs with Karma, it will silently hang in the console and in the browser.

It looks like this:

INFO [karma]: Karma v0.10.9 server started at http://localhost:9876/
INFO [launcher]: Starting browser Chrome
DEBUG [karma]: A browser has connected on socket ogZNbL65rO4qIuDxrNDB
DEBUG [karma]: All browsers are ready, executing

The browser opens, but the specs never execute.

The Solution: Raise The Open File Limit

Run the following command in your terminal to raise the maximum number of open file descriptors to a soft limit (a warning) of 1024, and a hard limit (blocks file from being opened) of 2048:

launchctl limit maxfiles 1024 2048

Bonus Round: Persist The Open File Limit

To persist this setting across system restarts, you need to create /etc/launchd.conf, then put the following line in it:

limit maxfiles 1024 2048