Increasing limits for socket descriptors on Ubuntu for RabbitMQ

Max Kimambo
Thoughts of a software fundi
1 min readNov 17, 2016

We recently ran into some issue regarding the number of open connections on one of our RabbitMQ servers, the number of socket connections was totally exhausted, and this prevented new clients from connecting to the message broker.

**The Problem**
![](/content/images/2016/11/Screen-Shot-2016–11–17-at-13.44.39.png)

As you can see there are only 1024 File descriptors available and even less connections, ssh’ing into the server we can check the limit via
```
ulimit -n
1024
```
To check for the hard limit do this.
```
ulimit -Hn
4096
```

These are default limits on distors like Debian and Ubuntu.

Most default installations are not configured for RabbitMQ production workloads.

**The solution**

Increase / Set maximum number of open files

```
sudo sysctl -w fs.file-max=65536
```

These limits are defined in /etc/security/limits.conf

```
sudo nano /etc/security/limits.conf
```
and set
```
soft nofile 65536
hard nofile 65536
```
Per user settings for rabbitmq process can also be set in
/etc/default/rabbitmq-server

```
sudo nano /etc/default/rabbitmq-server
```

and set

```
ulimit -n 65536
```

Then reboot the server for changes to take effect.

You should see this, once everything is backup and running.
![ ](/content/images/2016/11/Screen-Shot-2016–11–17-at-14.03.48.png)

Hope this helps if you are in a similar situation.

--

--