# log4j:ERROR Could not connect to remote log4j server at Logstash-server-IP

**URL:** <https://discuss.elastic.co/t/log4j-error-could-not-connect-to-remote-log4j-server-at-logstash-server-ip/143094>\
**Category:** Logstash\
**Created:** [August 6, 2018, 6:09am UTC](https://discuss.elastic.co/t/log4j-error-could-not-connect-to-remote-log4j-server-at-logstash-server-ip/143094 "2018-08-06T06:09:53Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ankita\_Ghate](https://avatars.discourse-cdn.com/v4/letter/a/f6c823/32.png) [@Ankita\_Ghate](https://discuss.elastic.co/u/Ankita_Ghate)\
**Post date:** [August 6, 2018, 6:09am UTC](https://discuss.elastic.co/t/log4j-error-could-not-connect-to-remote-log4j-server-at-logstash-server-ip/143094/1 "2018-08-06T06:09:53Z")

</div>

Hello,

Below is the application log4j.xml file,

\<?xml version="1.0" encoding="UTF-8" ?\>

\<log4j:configuration xmlns:log4j="[http://jakarta.apache.org/log4j/](http://jakarta.apache.org/log4j/)"  
debug="true"\>

\</log4j:configuration\>

And below is the logstash configuration file for same application,

input {  
log4j {  
mode =\> "server"  
port =\> 4994  
type =\> "log4j"  
}  
}

output {  
stdout {}  
elasticsearch { codec =\> rubydebug  
hosts =\> "ElasticsearchIP"  
index =\> "login"  
}  
}

Below are the logs of my spark application executor,

log4j:ERROR Could not connect to remote log4j server at [[LogstashHostname.example.com](http://LogstashHostname.example.com)]. We will try again later.

And below are the logs of spark application driver,

log4j: Attempting connection to [LogstashHostname.example.com](http://LogstashHostname.example.com)  
log4j: Remote host [LogstashHostname.example.com](http://LogstashHostname.example.com) refused connection.  
log4j: Attempting connection to [LogstashHostname.example.com](http://LogstashHostname.example.com)  
log4j: Remote host [LogstashHostname.example.com](http://LogstashHostname.example.com) refused connection.  
log4j: Attempting connection to [LogstashHostname.example.com](http://LogstashHostname.example.com)  
log4j: Remote host [LogstashHostname.example.com](http://LogstashHostname.example.com) refused connection.  
log4j: Attempting connection to [LogstashHostname.example.com](http://LogstashHostname.example.com)  
log4j: Remote host [LogstashHostname.example.com](http://LogstashHostname.example.com) refused connection.

Can you please let me know what can be the cause of these errors?

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [August 6, 2018, 6:13am UTC](https://discuss.elastic.co/t/log4j-error-could-not-connect-to-remote-log4j-server-at-logstash-server-ip/143094/2 "2018-08-06T06:13:55Z")

</div>

Check that

- Logstash is actually starting up properly,
- that it's listening on port 4994 (use e.g. netstat), and
- that there's no firewall blocking the access.

Please note that the log4j input has been depreacted. I strongly suggest you don't use it.

---

<div class="post-metadata">

**Author:** ![Ankita\_Ghate](https://avatars.discourse-cdn.com/v4/letter/a/f6c823/32.png) [@Ankita\_Ghate](https://discuss.elastic.co/u/Ankita_Ghate)\
**Post date:** [August 6, 2018, 6:33am UTC](https://discuss.elastic.co/t/log4j-error-could-not-connect-to-remote-log4j-server-at-logstash-server-ip/143094/3 "2018-08-06T06:33:37Z")

</div>

@magnusbaeck Thanks for the reply.

All above scenarios, I have checked. No issue with that.

Can you please suggest alternative for log4j for spark applications and Ignite logs/

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [August 6, 2018, 6:52am UTC](https://discuss.elastic.co/t/log4j-error-could-not-connect-to-remote-log4j-server-at-logstash-server-ip/143094/4 "2018-08-06T06:52:44Z")

</div>

The log4j plugin documentation suggests what should be used instead.

---

<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:** [September 3, 2018, 6:52am UTC](https://discuss.elastic.co/t/log4j-error-could-not-connect-to-remote-log4j-server-at-logstash-server-ip/143094/5 "2018-09-03T06:52:45Z")

</div>

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