Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PC×
Skip to content
VGSources
Blog

How to Fix a 502 Bad Gateway After Installing the ELK Stack

A 502 after installing ELK is usually an upstream readiness, connectivity, version, TLS or reverse-proxy mismatch. This guide walks through direct Kibana and Elasticsearch tests, Nginx checks, path handling and Logstash-specific failures.
Length8 min Posted Quest giverVGSources Team

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

A 502 after an ELK installation means the gateway cannot obtain a valid response from an upstream service. Test Kibana and Elasticsearch directly first, then correct version mismatches, proxy addressing, TLS and path settings, and timeout values; changing Nginx blindly can hide the failed hop.

What the 502 is actually telling you

Your browser is usually talking to Nginx, an ingress controller, or another load balancer rather than to Kibana itself. That gateway then connects to an upstream. A 502 is generated when the gateway receives no usable response or an invalid one. The failed upstream may be Kibana, Elasticsearch, or—during data delivery—a separate Logstash HTTP destination.

As an Amazon Associate I earn from qualifying purchases.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Draw the request path before changing settings:

  • Browser to gateway: the public host and port you open.
  • Gateway to Kibana: normally Kibana’s HTTP listener.
  • Kibana to Elasticsearch: the Elasticsearch URL configured in Kibana.
  • Optional data path: Logstash HTTP output to another service.

A successful browser request does not prove every hop is healthy. Test each hop from the machine that initiates it, using the same hostname, scheme, port and path that the configuration uses.

Use this diagnostic order

  1. Query Kibana’s status endpoint locally.
  2. Read Kibana startup and readiness logs.
  3. From the Kibana host, test its configured Elasticsearch URL, authentication and TLS trust.
  4. Confirm every Elastic Stack component is on the same release.
  5. Inspect the gateway’s upstream host, port, protocol, headers, path and timeouts.
  6. If the failure is limited to Discover or searches, investigate the Elasticsearch-facing proxy hop separately.
  7. If the symptom concerns ingestion, inspect Logstash HTTP output retries and transport settings.

This sequence separates an application that is not ready from a gateway that is pointed at the wrong place.

#1 Best Overall

Check Kibana without the gateway

Run these commands on the Kibana host, or from a machine that can reach its listener:

curl -i http://localhost:5601/status
curl -sS http://localhost:5601/api/status

Kibana’s documented default HTTP port is 5601. Local configuration can change it, so substitute the actual listener if you have set a different value. The /status endpoint is useful for a human-readable check; /api/status returns JSON that exposes overall status and core-plugin health.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Interpret the result

  • HTTP response with healthy or available status: Kibana is answering locally. Concentrate on the gateway’s upstream definition, protocol, path and certificate handling.
  • Connection refused: no process is listening on that address and port, Kibana failed to start, or it is bound to another interface or port.
  • Connection timeout: a local firewall, bind address, container network or security rule is preventing the connection.
  • HTTP 503 or a status showing startup: Kibana is running but not ready. Do not treat a temporary startup response as proof that Nginx is misconfigured.
  • TLS or hostname errors: you tested an HTTPS listener with an HTTP URL, used the wrong certificate name, or reached a different service than expected.

If localhost works but the public URL returns 502, the application and gateway are no longer the same test. Compare the successful local address with the exact upstream address configured in the proxy.

Read Kibana’s startup and readiness logs

Inspect the service manager, container, or orchestration logs for the period when the 502 began. Look for Elasticsearch connection failures, authentication errors, certificate validation messages, migration failures, plugin exceptions and bind-address or port errors. Kibana’s troubleshooting documentation groups guidance for server logs, readiness, Elasticsearch query tracing, monitoring, migrations, alerts and diagnostics.

A newly installed instance can take longer to become ready after plugin or setting changes. Browser resources may be re-optimized during startup, extending the interval before Kibana serves normal requests. If logs show active initialization and the status endpoint eventually becomes healthy, wait for that transition instead of repeatedly restarting the service or changing the proxy.

When logs indicate a real startup failure

  • Correct the first fatal error, then restart once and watch the complete startup sequence.
  • Verify that the configured Elasticsearch address is resolvable from the Kibana process, not merely from your workstation.
  • Check that the service account can read its configuration, certificates and data directories.
  • Confirm that the configured port is free and that Kibana is listening on the interface the gateway reaches.

Capture timestamps for the first failed request and the corresponding log entries. That correlation helps distinguish a transient readiness window from a persistent upstream failure.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Verify Elasticsearch from the Kibana host

Kibana must reach the Elasticsearch URL in its configuration. Elasticsearch’s documented default REST port is 9200; its transport port is 9300. The transport port is not the HTTP API and should not be used for Kibana’s URL.

curl -i http://127.0.0.1:9200/
curl -i http://elasticsearch-host:9200/

Use the configured hostname rather than assuming loopback is correct. If security is enabled, test with the same authentication method and HTTPS scheme that Kibana uses. A certificate chain that is trusted by your shell’s curl may still be unavailable to Kibana’s trust store, and the reverse can also occur.

Classify the Elasticsearch response

Direct result Likely meaning Next check
HTTP response from the expected node The network path is open. Compare Kibana credentials, TLS trust and the configured URL character for character.
Connection refused Elasticsearch is stopped, listening elsewhere, or blocked locally. Check the Elasticsearch service state, bind address and port.
Timeout Routing, firewall or security-group rules prevent the connection. Test from the Kibana host and permit the actual source and destination.
Certificate or hostname error The HTTPS certificate cannot be validated for the name used. Correct the scheme, trust chain or hostname; do not disable verification as a permanent fix.
401 or 403 Elasticsearch answered, but authentication or authorization is wrong. Correct Kibana’s credentials and required privileges.

Firewalls and security groups must permit the configured path, not merely the documented defaults. A service moved to another host or port requires the same change in Kibana and in any proxy that fronts it.

Align all Elastic Stack versions

Elastic’s deployment guidance states that the entire stack must use the same version. Check Elasticsearch, Kibana, Logstash, Beats and APM packages together; do not assume that a minor package difference is harmless. Mixed versions can produce migration, API or plugin failures that appear to the gateway as an unavailable Kibana upstream.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Record the installed version of each component and compare it with the repository or package version used for the installation. Correct the mismatch using the supported upgrade or downgrade path, then let Kibana complete its migrations before judging the proxy configuration.

Inspect the reverse proxy one setting at a time

Once Kibana answers directly, inspect the gateway’s upstream block and error log. The upstream hostname must resolve from the gateway machine, and the port must be Kibana’s actual listener. A gateway pointed at Elasticsearch’s transport port, an old container address or an unused loopback interface will produce a 502 even when Kibana itself is healthy.

Protocol and certificate handling

  • Use http:// upstream when Kibana serves plain HTTP and https:// when it serves TLS.
  • If the upstream is HTTPS, verify the certificate chain and hostname according to your gateway’s settings.
  • Do not enable certificate verification against an address that the certificate does not cover; fix the name or trust configuration instead.
  • Check that the public listener’s HTTP-to-HTTPS redirect does not create a loop back to the gateway.

Headers and host behavior

Pass a suitable Host header and the usual forwarding headers required by your deployment, such as the original scheme and client address. An incorrect host can make Kibana generate unusable links or reject a request when host validation is enabled. Compare the headers sent by a known-good direct request with those sent through the gateway.

Root paths and subpaths

A proxy that publishes Kibana at a subpath must agree with Kibana’s server.basePath and related public URL settings. If Nginx removes /kibana but Kibana expects it, or preserves it when Kibana expects the root path, status requests may work while application assets or API calls fail. Test both the root and the published path deliberately, and keep the rewrite behavior consistent for HTML, static assets and API requests.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Connect and read timeouts

A connect timeout usually indicates an unreachable upstream. A read timeout can occur while Kibana is still starting or while a request waits on Elasticsearch. Set values appropriate to the service, but do not use a very long timeout to conceal a failed dependency. The proxy error log normally identifies whether the event was a refused connection, a timeout, a name-resolution error or an invalid upstream response.

Use the gateway log as the deciding evidence

Check the error log at the exact time of a failed request. Messages naming an upstream address, certificate problem or timeout tell you which hop failed. If the log says the upstream returned malformed headers or closed the connection, return to Kibana logs; if it names an unreachable address, correct DNS, routing or the upstream definition first.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

When only Discover or searches return 502

A login page or Kibana home screen can load while requests that query Elasticsearch fail. That pattern points to the Elasticsearch-facing path rather than the browser-to-Kibana connection. Inspect the proxy route used for search and data requests, including its upstream host, port, HTTPS settings, authentication headers, body-size limits and timeout values. Review both the gateway log and Elasticsearch log for the same request time.

Do not conclude that Kibana caused the error merely because the browser displays it inside Kibana. An Elasticsearch request handled by a separate proxy route can generate the 502 after Kibana has already served the page successfully.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Check Logstash HTTP output separately

If the symptom is failed delivery from Logstash rather than a Kibana page, inspect the HTTP output plugin configuration. The official plugin reference lists 429, 500, 502, 503 and 504 as retryable response codes when retry_failed is enabled. It also documents proxy, socket-timeout and TLS controls.

Confirm the destination URL, proxy address, TLS trust and socket timeout used by the Logstash process. A retrying Logstash pipeline can create repeated 502 entries without indicating that Kibana is down. Check the destination service’s logs and the Logstash event log together, and size retries so they do not overwhelm a recovering endpoint.

A practical recovery procedure

  1. Note the public URL, timestamp and exact request that returned 502.
  2. Run the Kibana status commands locally and save the status code and JSON result.
  3. Read Kibana logs for readiness, migration, plugin, Elasticsearch and TLS errors.
  4. From the Kibana host, call the configured Elasticsearch URL using its real scheme, hostname, port and authentication.
  5. Record versions for Elasticsearch, Kibana, Logstash, Beats and APM, and correct any mismatch.
  6. From the gateway host, resolve and connect to the exact Kibana upstream address.
  7. Compare HTTP versus HTTPS, certificate verification, Host and forwarding headers, path rewrites and base-path settings.
  8. Use the gateway error log to adjust only the setting associated with the observed failure.
  9. Retest the direct status endpoint, the proxied status endpoint, the Kibana UI and a representative search.
  10. If ingestion is the issue, test Logstash output independently rather than changing Kibana’s proxy route.

Retest after each change so a successful result identifies the fix. Restarting every component at once removes the evidence needed to locate the failed hop.

Share diagnostics without exposing secrets

Logs and diagnostic output can contain product metadata and settings. Before posting them, remove credentials, bearer tokens, certificate contents, private hostnames, internal IP addresses and other values that would disclose your environment. Preserve timestamps, status codes, endpoint paths, error class and the relevant configuration keys; those details are usually enough for another administrator to identify the failing connection without receiving secrets.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Quick Recap

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More quests from Patch Notes

  1. How to Set Up a RedM (RDR2) Server in 2026: License Key, txAdmin and server.cfg, Step by StepBlog11min
  2. Best RedM (RDR2) Server Hosting in 2026: Comparing Four Hosts on Slots, Memory and PriceBlog10min
  3. How to Host a Mindustry Server in 2026: server-release.jar, Port 6567 and the Commands That MatterBlog7min
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.