# Metricbeat for NGINX : HTTP error 502 in : 502 Bad Gateway

**URL:** <https://discuss.elastic.co/t/metricbeat-for-nginx-http-error-502-in-502-bad-gateway/299155>\
**Category:** Elastic Training\
**Created:** [March 9, 2022, 1:02am UTC](https://discuss.elastic.co/t/metricbeat-for-nginx-http-error-502-in-502-bad-gateway/299155 "2022-03-09T01:02:51Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![elasticmind](https://avatars.discourse-cdn.com/v4/letter/e/ec9cab/32.png) [@elasticmind](https://discuss.elastic.co/u/elasticmind)\
**Post date:** [March 9, 2022, 1:02am UTC](https://discuss.elastic.co/t/metricbeat-for-nginx-http-error-502-in-502-bad-gateway/299155/1 "2022-03-09T01:02:51Z")

</div>

Hello,

I'm going through the observability fundamentals training and for the NGINX metrics section i'm getting this error:

{"log.level":"error","@timestamp":"2022-03-09T00:57:04.303Z","log.origin":{"file.name":"module/wrapper.go","file.line":254},"message":"Error fetching data for metricset nginx.stubstatus: error fetching status: HTTP error 502 in : 502 Bad Gateway","service.name":"metricbeat","ecs.version":"1.6.0"}

the nginx.yml file configure is below:

```auto
- module: nginx
  #metricsets:
  # - stubstatus
  period: 10s

  # Nginx hosts
  hosts: ["http://127.0.0.1"]

  # Path to server status. Default nginx_status
  #server_status_path: "nginx_status"

  username: "training"
  password: "nonprodpwd"

```

---

<div class="post-metadata">

**Author:** ![Andre\_Murbach\_Maidl](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/andre_murbach_maidl/32/83508_2.png) [@Andre\_Murbach\_Maidl](https://discuss.elastic.co/u/Andre_Murbach_Maidl)\
**Post date:** [March 9, 2022, 12:24pm UTC](https://discuss.elastic.co/t/metricbeat-for-nginx-http-error-502-in-502-bad-gateway/299155/2 "2022-03-09T12:24:36Z")

</div>

Hi @elasticmind,

please try setting `server_status_path` to `server-status` as follows:

```auto
server_status_path: "server-status"

```

This should solve the issue.

Best,  
Andre

---

<div class="post-metadata">

**Author:** ![elasticmind](https://avatars.discourse-cdn.com/v4/letter/e/ec9cab/32.png) [@elasticmind](https://discuss.elastic.co/u/elasticmind)\
**Post date:** [March 10, 2022, 7:09am UTC](https://discuss.elastic.co/t/metricbeat-for-nginx-http-error-502-in-502-bad-gateway/299155/3 "2022-03-10T07:09:19Z")

</div>

Will try this out.

So to clarify, it should be not commented out?

---

<div class="post-metadata">

**Author:** ![Andre\_Murbach\_Maidl](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/andre_murbach_maidl/32/83508_2.png) [@Andre\_Murbach\_Maidl](https://discuss.elastic.co/u/Andre_Murbach_Maidl)\
**Post date:** [March 10, 2022, 1:48pm UTC](https://discuss.elastic.co/t/metricbeat-for-nginx-http-error-502-in-502-bad-gateway/299155/4 "2022-03-10T13:48:26Z")

</div>

Yes, you will need to uncomment that line to change the default setting.

Best,  
Andre

---

<div class="post-metadata">

**Author:** ![elasticmind](https://avatars.discourse-cdn.com/v4/letter/e/ec9cab/32.png) [@elasticmind](https://discuss.elastic.co/u/elasticmind)\
**Post date:** [March 10, 2022, 4:49pm UTC](https://discuss.elastic.co/t/metricbeat-for-nginx-http-error-502-in-502-bad-gateway/299155/5 "2022-03-10T16:49:32Z")

</div>

Thanks, it worked.

What could be the reason why it was not working for the nginx metric but worked for the system metrics with the server\_status\_path commented out?

---

<div class="post-metadata">

**Author:** ![Andre\_Murbach\_Maidl](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/andre_murbach_maidl/32/83508_2.png) [@Andre\_Murbach\_Maidl](https://discuss.elastic.co/u/Andre_Murbach_Maidl)\
**Post date:** [March 10, 2022, 5:36pm UTC](https://discuss.elastic.co/t/metricbeat-for-nginx-http-error-502-in-502-bad-gateway/299155/6 "2022-03-10T17:36:12Z")

</div>

That's great to hear it worked @elasticmind. That's because this is a specific setting for NGINX metrics.

Best,  
Andre

---

<div class="post-metadata">

**Author:** ![elasticmind](https://avatars.discourse-cdn.com/v4/letter/e/ec9cab/32.png) [@elasticmind](https://discuss.elastic.co/u/elasticmind)\
**Post date:** [March 11, 2022, 11:08am UTC](https://discuss.elastic.co/t/metricbeat-for-nginx-http-error-502-in-502-bad-gateway/299155/7 "2022-03-11T11:08:48Z")

</div>

Thanks for your help, i appreciate it.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [April 8, 2022, 11:09am UTC](https://discuss.elastic.co/t/metricbeat-for-nginx-http-error-502-in-502-bad-gateway/299155/8 "2022-04-08T11:09:26Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
