Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

worker_connections are not enough

Tags:

nginx

kibana

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 *;
       }
like image 468
dReAmEr Avatar asked Feb 01 '15 17:02

dReAmEr


2 Answers

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;
}
like image 153
RASG Avatar answered Oct 24 '22 06:10

RASG


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 :)

like image 38
chrskly Avatar answered Oct 24 '22 05:10

chrskly