Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

Apache nifi. Can't connect to Elastisearch due to a connection refused error

avatar
New Contributor

Hi there!

I'm facing a connection refused problem in my apache nifi instance trying to reach an Elasticsearch instance using a queryElasticsearchHttp processor.

The elasticsearch instance is reachable using CURL or in a web browser:

Elastic_Error_1.jpg

But when I try to execute the processor, it fails due to a connection refused error

Here is the configuration I have in the processor:

Elastic_Error_2.jpg

 

The server is not secured, but anyway I also tried to access with a valid user/password, facing the same error.

Here my log:

 

 

2023-11-24 09:03:14 2023-11-24 08:03:14,682 ERROR [Timer-Driven Process Thread-4] o.a.n.p.e.QueryElasticsearchHttp QueryElasticsearchHttp[id=018b15d7-f6fe-11ed-b48b-3fd75e47c7d4] Failed to read from Elasticsearch due to Failed to connect to localhost/127.0.0.1:9200, this may indicate an error in configuration (hosts, username/password, etc.). Routing to retry
2023-11-24 09:03:14 java.net.ConnectException: Failed to connect to localhost/127.0.0.1:9200
2023-11-24 09:03:14     at okhttp3.internal.connection.RealConnection.connectSocket(RealConnection.kt:297)
2023-11-24 09:03:14     at okhttp3.internal.connection.RealConnection.connect(RealConnection.kt:207)
2023-11-24 09:03:14     at okhttp3.internal.connection.ExchangeFinder.findConnection(ExchangeFinder.kt:226)
2023-11-24 09:03:14     at okhttp3.internal.connection.ExchangeFinder.findHealthyConnection(ExchangeFinder.kt:106)
2023-11-24 09:03:14     at okhttp3.internal.connection.ExchangeFinder.find(ExchangeFinder.kt:74)
2023-11-24 09:03:14     at okhttp3.internal.connection.RealCall.initExchange$okhttp(RealCall.kt:255)
2023-11-24 09:03:14     at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.kt:32)
2023-11-24 09:03:14     at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
2023-11-24 09:03:14     at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.kt:95)
2023-11-24 09:03:14     at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
2023-11-24 09:03:14     at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.kt:83)
2023-11-24 09:03:14     at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
2023-11-24 09:03:14     at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.kt:76)
2023-11-24 09:03:14     at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
2023-11-24 09:03:14     at okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(RealCall.kt:201)
2023-11-24 09:03:14     at okhttp3.internal.connection.RealCall.execute(RealCall.kt:154)
2023-11-24 09:03:14     at org.apache.nifi.processors.elasticsearch.AbstractElasticsearchHttpProcessor.sendRequestToElasticsearch(AbstractElasticsearchHttpProcessor.java:269)
2023-11-24 09:03:14     at org.apache.nifi.processors.elasticsearch.QueryElasticsearchHttp.onTrigger(QueryElasticsearchHttp.java:352)
2023-11-24 09:03:14     at org.apache.nifi.processor.AbstractProcessor.onTrigger(AbstractProcessor.java:27)
2023-11-24 09:03:14     at org.apache.nifi.controller.StandardProcessorNode.onTrigger(StandardProcessorNode.java:1361)
2023-11-24 09:03:14     at org.apache.nifi.controller.tasks.ConnectableTask.invoke(ConnectableTask.java:247)
2023-11-24 09:03:14     at org.apache.nifi.controller.scheduling.AbstractTimeBasedSchedulingAgent.lambda$doScheduleOnce$0(AbstractTimeBasedSchedulingAgent.java:59)
2023-11-24 09:03:14     at org.apache.nifi.engine.FlowEngine$2.run(FlowEngine.java:110)
2023-11-24 09:03:14     at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
2023-11-24 09:03:14     at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
2023-11-24 09:03:14     at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source)
2023-11-24 09:03:14     at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
2023-11-24 09:03:14     at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
2023-11-24 09:03:14     at java.base/java.lang.Thread.run(Unknown Source)
2023-11-24 09:03:14 Caused by: java.net.ConnectException: Connection refused (Connection refused)
2023-11-24 09:03:14     at java.base/java.net.PlainSocketImpl.socketConnect(Native Method)
2023-11-24 09:03:14     at java.base/java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
2023-11-24 09:03:14     at java.base/java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
2023-11-24 09:03:14     at java.base/java.net.AbstractPlainSocketImpl.connect(Unknown Source)
2023-11-24 09:03:14     at java.base/java.net.SocksSocketImpl.connect(Unknown Source)
2023-11-24 09:03:14     at java.base/java.net.Socket.connect(Unknown Source)
2023-11-24 09:03:14     at okhttp3.internal.platform.Platform.connectSocket(Platform.kt:128)
2023-11-24 09:03:14     at okhttp3.internal.connection.RealConnection.connectSocket(RealConnection.kt:295)

 

 

1 ACCEPTED SOLUTION

avatar
New Contributor

Hi!

Thanks for your response. Now the problem is solved!
I was not able to connect due to that nifi was effectively installed in a docker in my computer, so, even the computer had access to the mongo database, the docker not.

Now I solved the problem and can continue working on it! Thanks again!

View solution in original post

2 REPLIES 2

avatar
Super Collaborator

The address you're trying to hit is "localhost". By any chance are you running ES in a Docker container on your machine? If so, have you exposed that port so that systems outside your own can access it? If you have, try changing localhost to your machines IP address in your NiFi ES processor config.

 

avatar
New Contributor

Hi!

Thanks for your response. Now the problem is solved!
I was not able to connect due to that nifi was effectively installed in a docker in my computer, so, even the computer had access to the mongo database, the docker not.

Now I solved the problem and can continue working on it! Thanks again!