How to fix the “too many open sockets” error


Sometimes our clients will get a “too many open sockets” error on very busy servers. This error occurs when you try to open more than 2048 socket connections for an instance of Iguana.

This error has several variations but will always contain the string “too many open sockets (FD_SETSIZE=2048 reached)“.

If you have any questions please contact us at

Issue [top]

The “too many open sockets” error occurs when you try to open more than 2048 socket connections for an instance of Iguana.

Solution [top]

  1. Check how many open sockets you have:
    1. Run the socket diagnostic command:
      http://localhost:<Iguana port number>/socket_diagnostic.html

      For example using the default 6543 port:

    2. The results will look something like this:
      socket diagnostic

      Note: In this case the number of ports is low and will not be causing any issues.

      Our support staff will usually request screenshot of this result – as it can be very helpful for diagnosing this error.

  2. Reduce the socket timeout setting:

    The default socket timeout for Iguana is 120 seconds, for high transactions systems this will need to be reduced – the minimum setting is one second. For systems with extremely high transaction volumes there may be more transactions than a single Iguana instance can process – in this case you can split the processing between several Iguana servers.

    1. Adjust the IGUANA_WEB_SOCKET_IDLE_TIMEOUT_SECONDS system variable to a lower value (default is 120 seconds) – you can set it as low as one second:
    2. The best way to manage this variable is usually through Iguana > Settings > Environment Variables:

      Using the Iguana settings to manage environment variables means the changes are local to that specific Iguana server – so they do not affect other Iguana servers on the same machine (this is usually the desired behaviour). You can also manage the environment variable through the operating system but this will affect all Iguana instances on the machine.

      1. Add IGUANA_WEB_SOCKET_IDLE_TIMEOUT_SECONDS in Settings > Environment Variables.
      2. Click the Add Variable button to add the variable:
        environment variable
      3. Click the SAVE to save the settings – if the variable already exists the Value will updated instead.
    3. Alternatively you can set the IGUANA_WEB_SOCKET_IDLE_TIMEOUT_SECONDS system variable using the operating system – but be aware that this will affect all instances of Iguana on the machine.
  3. Check that the code does not allow the number of socket connections to continually increase:

    This is basically checking for “connection leaks” in the the same way as you would check code for memory or other resource leaks – this is particularly important for long running programs as any “leak” will eventually reach the system limit

    1. Make sure connections are closed as soon as possible.
    2. Set limits on the maximum number of connections.
  4. You can also review the Socket management section of Tuning a large scale Iguana install – this article was originally written for Iguana 5, but the principles remain the same for Iguana 6.
  5. In the unlikely situation where you actually need more than 2048 sockets you can split the processing between multiple Iguana servers.

Leave A Comment?