NGINX connection refused
search cancel

NGINX connection refused

book

Article ID: 271911

calendar_today

Updated On:

Products

DX SaaS

Issue/Introduction

After deploying APM Agent to monitor an NGINX server, the agent logs show the below exception and no metrics are seeing:

[DEBUG] [IntroscopeAgent.Nginx] Querying with URL: http://HostName:9090/stub_status
[ERROR] [IntroscopeAgent.Nginx] Error while querying the Nginx Stub Status API 
[DEBUG] [IntroscopeAgent.Nginx] Connection refused
java.net.ConnectException: Connection refused
    at java.base/sun.nio.ch.Net.connect0(Native Method)
    at java.base/sun.nio.ch.Net.connect(Unknown Source)
    at java.base/sun.nio.ch.Net.connect(Unknown Source)
    at java.base/sun.nio.ch.NioSocketImpl.connect(Unknown Source)
    at java.base/java.net.Socket.connect(Unknown Source)
    at java.base/java.net.Socket.connect(Unknown Source)
    at java.base/sun.net.NetworkClient.doConnect(Unknown Source)
    at java.base/sun.net.www.http.HttpClient.openServer(Unknown Source)
    at java.base/sun.net.www.http.HttpClient.openServer(Unknown Source)
    at java.base/sun.net.www.http.HttpClient.<init>(Unknown Source)
    at java.base/sun.net.www.http.HttpClient.New(Unknown Source)
    at java.base/sun.net.www.http.HttpClient.New(Unknown Source)
    at java.base/sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(Unknown Source)
    at java.base/sun.net.www.protocol.http.HttpURLConnection.plainConnect0(Unknown Source)
    at java.base/sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source)
    at java.base/sun.net.www.protocol.http.HttpURLConnection.connect(Unknown Source)
    at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream0(Unknown Source)
    at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
    at java.base/java.net.URLConnection.getContent(Unknown Source)
    at com.ca.apm.extensions.nginx.utils.NginxUtils.processGetRequest(NginxUtils.java:79)
    at com.ca.apm.extensions.nginx.NginxStubStatusReader.getStubStatusData(NginxStubStatusReader.java:174)
    at com.ca.apm.extensions.nginx.NginxStubStatusReader.process(NginxStubStatusReader.java:119)
    at com.ca.apm.extensions.nginx.NginxStubStatusReaderInvoker$1.run(NginxStubStatusReaderInvoker.java:60)
    at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
    at java.base/java.util.concurrent.FutureTask.runAndReset(Unknown Source)
    at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.base/java.lang.Thread.run(Unknown Source)

Environment

Release : SAAS

Resolution

If the agent is hosted at the same server as Ngionx, make sure to have the below permission into Nginx.conf:

server
  {
  listen 127.0.0.1:80;
  server_name 127.0.0.1;
  location /stub_status
  {
  stub_status on;
  allow 127.0.0.1;
  deny all;
  }
}