worker_connections are not enough

NginxKibana

Nginx Problem Overview


I am trying access kibana application deployed in nginx,but getting below

URL :- http://127.0.0.1/kibana-3.1.2

2015/02/01 23:05:05 [alert] 3919#0: *766 768 worker_connections are not enough while connecting to upstream, client: 127.0.0.1, server: , request: "GET /kibana-3.1.2 HTTP/1.0", upstream: "http://127.0.0.1:80/kibana-3.1.2", host: "127.0.0.1"

Kibana is deployed at /var/www/kibana-3.1.2

I have tried to increase the worker_connections,but still no luck,getting below in this case.

2015/02/01 23:02:27 [alert] 3802#0: accept4() failed (24: Too many open files)
2015/02/01 23:02:27 [alert] 3802#0: accept4() failed (24: Too many open files)
2015/02/01 23:02:27 [alert] 3802#0: accept4() failed (24: Too many open files)
2015/02/01 23:02:27 [alert] 3802#0: accept4() failed (24: Too many open files)
2015/02/01 23:02:27 [alert] 3802#0: accept4() failed (24: Too many open files)

nginx.conf :-

user www-data;
worker_processes 4;
pid /var/run/nginx.pid;

events {
        worker_connections 768;
        # multi_accept on;
}

And below in the location directive.

location /kibana-3.1.2{

        proxy_set_header X-Real-IP  $remote_addr;

        proxy_set_header X-Forwarded-For $remote_addr;

        proxy_set_header Host $host;

        proxy_pass http://127.0.0.1;

        add_header Access-Control-Allow-Origin *;

        add_header Access-Control-Allow-Headers *;
       }

Nginx Solutions


Solution 1 - Nginx

Old question, but i had the same issue and the accepted answer didnt work for me.

I had to increase the number of worker_connections, as stated here.

/etc/nginx/nginx.conf

events {
    worker_connections 20000;
}

Solution 2 - Nginx

Not quite enough info to say definitively, but based on the config you've provided, it looks like you have loop. You're proxying the requests to localhost:80, but NGINX is most likely listening on port 80. So, NGINX is connecting to itself over and over, hence the errors about too many open files.

Also, Kibana doesn't have any server-side code, so proxy_pass isn't appropriate here. Something like the following should be enough:

root /var/www/
location /kibana-3.1.2 {
    try_files $uri $uri/ =404;
}

With that being said, if you intend for this to be accessible from the public internet, you should protect it with a password and you should use proxy_pass in front of elasticsearch to control what requests can be made to it. But that's a different story :)

Solution 3 - Nginx

If you are running this on docker containers with a connection to a php container, in yor nginx config or website config change fastcgi_pass 127.0.0.1:9000; to fastcgi_pass php:9000; This is because nginx points to localhost and thinks it is the same container that it his running instead of routing to another container

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestiondReAmErView Question on Stackoverflow
Solution 1 - NginxRASGView Answer on Stackoverflow
Solution 2 - NginxchrsklyView Answer on Stackoverflow
Solution 3 - NginxLuis Miguel SilvaView Answer on Stackoverflow