Question

Installed ELk Log Stack gives 502 Bad Gateway

Hi,

I just installed Elk Log Stack with one click install on Ubuntu 14.04,

When i logged into the ip with the user password as described in: https://www.digitalocean.com/community/tutorials/how-to-use-the-digitalocean-elk-stack-one-click-application

Then I get a Nginx 502 Bad Gateway, i have following in the /var/log/nginx/error.log

2015/07/26 08:57:40 [error] 934#0: *3 connect() failed (111: Connection refused) while connecting to upstream, client: 37.24.151.202, server: , request: “GET / HTTP/1.1”, upstream: “http://127.0.0.1:5601/”, host: “46.101.233.103” 2015/07/26 08:57:40 [error] 934#0: *3 connect() failed (111: Connection refused) while connecting to upstream, client: 37.24.151.202, server: , request: “GET /favicon.ico HTTP/1.1”, upstream: “http://127.0.0.1:5601/favicon.ico”, host: “46.101.233.103”, referrer: “http://46.101.233.103/

I’m new to the log stack and sort of new to nginx, and i expected the one click install to work out of the box… What can i do to fix this ?

Show comments

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

Check your kibana.yml file.

the server.host should be the same as what in the proxy_pass

nginx config proxy_pass http://localhost:5601;

kibana.yml server.host: “localhost”

after restart it should fix the bad gateway issue.

That’s strange,

I tried for the fun of it, to boot a new droplet in Frankfurt (1) still exact same result. Then i tried to boot on in New York (3) that worked.

Perhaps there are some problems at Frankfurt hosting right now.

Hi tomasnorre,

I installed also an Elk Log Stack with one click install on Ubuntu 14.04. But for me it worked fine. Your error was that the service kibana was not running. Maybe the droplet deployment of ELK Stack was not ready. How I found out the error see analysis:

Problem: 2015/07/26 08:57:40 [error] 934#0: *3 connect() failed (111: Connection refused) while connecting to upstream, client: 37.24.151.202, server: , request: “GET / HTTP/1.1”, upstream: “http://127.0.0.1:5601/”, host: “46.101.233.103”

Analysis:

Nginx trying to connect to localhost:5601

root # grep -r "5601" /etc/nginx/
/etc/nginx/sites-available/kibana:        proxy_pass http://localhost:5601;

I looked into /etc/nginx/sites-available/kibana:

root # cat /etc/nginx/sites-available/kibana 
server {
    listen 80;

    # server_name kibana.myhost.org;

    auth_basic "Restricted Access";
    auth_basic_user_file /etc/nginx/conf.d/kibana.htpasswd;

    location / {
        proxy_pass http://localhost:5601;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
    }
}

Nginx using a Reverse Proxy

To reproduce your error i stopped the kibana service

root # service kibana stop

Result: 502 Bad Gateway

Solution:

#check if kibana is running
root # service kibana status
root # netstat -pant | grep 5601
tcp        0      0 127.0.0.1:5601          0.0.0.0:*               LISTEN      2227/node
root # ps -ef | grep kibana | grep -v "grep "
kibana    2227     1  0 10:04 ?        00:00:01 /opt/kibana/bin/../node/bin/node /opt/kibana/bin/../src/bin/kibana.js

#if the service is not running 
root # service kibana start 

I hope this helped you.

Best regards, MSahl