# Logstash gives error "Error: Address already in use" when ingesting filebeat with two inputs

**URL:** https://discuss.elastic.co/t/logstash-gives-error-error-address-already-in-use-when-ingesting-filebeat-with-two-inputs/226168
**Category:** Logstash
**Created:** [April 2, 2020, 7:27am UTC](https://discuss.elastic.co/t/logstash-gives-error-error-address-already-in-use-when-ingesting-filebeat-with-two-inputs/226168 "2020-04-02T07:27:29Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![chintanp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/chintanp/32/58136_2.png) [@chintanp](https://discuss.elastic.co/u/chintanp)
#### Post date: [April 2, 2020, 7:27am UTC](https://discuss.elastic.co/t/logstash-gives-error-error-address-already-in-use-when-ingesting-filebeat-with-two-inputs/226168/1 "2020-04-02T07:27:29Z")

</div>

Hi,

I saw several similar posts, but none seemed to match my case.

I got the open-source [ELK stack from Bitnami](https://bitnami.com/stack/elk/cloud) and deployed it on AWS (Debian Linux 4.9). I am able to read the apache server logs locally, all the way through to Kibana. I am also able to read the NGINX on a remote development server (Ubuntu) that I want to monitor using the `nginx` filebeat module. Now, I want to add another input to the filebeat, I want to monitor the logs generated in a file from a NodeJS server that the NGINX server proxies.

I am able to get the logs from the filebeat, using the same port (5044), however, when I checked the `logstash.log`, I saw the following error at times:

```auto
 [2020-04-02T07:17:39,451][INFO][org.logstash.beats.Server][main] Starting server on port: 5044
[2020-04-02T07:17:45,665][ERROR][logstash.javapipeline][main] A plugin had an unrecoverable error. Will restart this plugin.
  Pipeline_id:main
  Plugin: <LogStash::Inputs::Beats host=>"0.0.0.0", id=>"filebeat_node", port=>5044, enable_metric=>true, codec=><LogStash::Codecs::Plain id=>"plain_6ad28135-8320-4528-bc21-2693fad9c61d", enable_metric=>true, charset=>"UTF-8">, ssl=>false, add_hostname=>false, ssl_verify_mode=>"none", ssl_peer_metadata=>false, include_codec_tag=>true, ssl_handshake_timeout=>10000, tls_min_version=>1, tls_max_version=>1.2, cipher_suites=>["TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384", "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384", "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256", "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256", "TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384", "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384", "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256", "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256"], client_inactivity_timeout=>60, executor_threads=>2>
  Error: Address already in use
  Exception: Java::JavaNet::BindException
  Stack: sun.nio.ch.Net.bind0(Native Method)
sun.nio.ch.Net.bind(sun/nio/ch/Net.java:455)
sun.nio.ch.Net.bind(sun/nio/ch/Net.java:447)
sun.nio.ch.ServerSocketChannelImpl.bind(sun/nio/ch/ServerSocketChannelImpl.java:227)
io.netty.channel.socket.nio.NioServerSocketChannel.doBind(io/netty/channel/socket/nio/NioServerSocketChannel.java:130)
io.netty.channel.AbstractChannel$AbstractUnsafe.bind(io/netty/channel/AbstractChannel.java:558)
io.netty.channel.DefaultChannelPipeline$HeadContext.bind(io/netty/channel/DefaultChannelPipeline.java:1358)
io.netty.channel.AbstractChannelHandlerContext.invokeBind(io/netty/channel/AbstractChannelHandlerContext.java:501)
io.netty.channel.AbstractChannelHandlerContext.bind(io/netty/channel/AbstractChannelHandlerContext.java:486)
io.netty.channel.DefaultChannelPipeline.bind(io/netty/channel/DefaultChannelPipeline.java:1019)
io.netty.channel.AbstractChannel.bind(io/netty/channel/AbstractChannel.java:254)
io.netty.bootstrap.AbstractBootstrap$2.run(io/netty/bootstrap/AbstractBootstrap.java:366)
io.netty.util.concurrent.AbstractEventExecutor.safeExecute(io/netty/util/concurrent/AbstractEventExecutor.java:163)
io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(io/netty/util/concurrent/SingleThreadEventExecutor.java:404)
io.netty.channel.nio.NioEventLoop.run(io/netty/channel/nio/NioEventLoop.java:462)
io.netty.util.concurrent.SingleThreadEventExecutor$5.run(io/netty/util/concurrent/SingleThreadEventExecutor.java:897)
io.netty.util.concurrent.FastThreadLocalRunnable.run(io/netty/util/concurrent/FastThreadLocalRunnable.java:30)
java.lang.Thread.run(java/lang/Thread.java:834)
[2020-04-02T07:17:46,666][INFO][org.logstash.beats.Server][main] Starting server on port: 5044

```

Subsequent logstash behavior is uncertain, sometimes it still decides to run with the exception above. When I tried `lsof -n -i :5044` I get one line for logstash and another with same PID for showing an "ESTABLISHED" connection to the remote machine I am listening from. Later when it does not work the `lsof` only shows the logstash process with no connection. I am also not using any other instance of ELK on the ELK machine.

My relevant part of filebeat.yml is as under:

```auto
- type: log 
  enabled: true
  paths:
    - /my/log/path*
  fields:
    log_type: city_dashboard_logs

```

Other filebeat settings are default and the `nginx` module was enabled. My logstash conf related to filebeat is as under:

```auto
input {
  beats {
    id => "filebeat_node"
    port => 5044
    host => "0.0.0.0"
  }
}
filter {
  if [event][module] == "nginx" {
    if [fileset][name] == "access" {
      grok {
        match => { "message" => ["%{IPORHOST:[nginx][access][remote_ip]} - %{DATA:[nginx][access][user_name]} \[%{HTTPDATE:[nginx][access][time]}\] \"%{WORD:[nginx][access][method]} %{DATA:[nginx][access][url]} HTTP/%{NUMBER:[nginx][access][http_version]}\" %{NUMBER:[nginx][access][response_code]} %{NUMBER:[nginx][access][body_sent][bytes]} \"%{DATA:[nginx][access][referrer]}\" \"%{DATA:[nginx][access][agent]}\""] }
        remove_field => "message"
      }
      mutate {
        add_field => { "read_timestamp" => "%{@timestamp}" }
      }
      date {
        match => ["[nginx][access][time]", "dd/MMM/YYYY:H:m:s Z" ]
        remove_field => "[nginx][access][time]"
      }
      useragent {
        source => "[nginx][access][agent]"
        target => "[nginx][access][user_agent]"
        remove_field => "[nginx][access][agent]"
      }
      geoip {
        source => "[nginx][access][remote_ip]"
        target => "[nginx][access][geoip]"
      }
    }
    else if [fileset][name] == "error" {
      grok {
        match => { "message" => ["%{DATA:[nginx][error][time]} \[%{DATA:[nginx][error][level]}\] %{NUMBER:[nginx][error][pid]}#%{NUMBER:[nginx][error][tid]}: (\*%{NUMBER:[nginx][error][connection_id]} )?%{GREEDYDATA:[nginx][error][message]}"] }
        remove_field => "message"
      }
      mutate {
        rename => { "@timestamp" => "read_timestamp" }
      }
      date {
        match => ["[nginx][error][time]", "YYYY/MM/dd H:m:s" ]
        remove_field => "[nginx][error][time]"
      }
    }
  }
}

output {
  elasticsearch {
    hosts => localhost
    manage_template => false
    index => "%{[@metadata][beat]}-%{[@metadata][version]}-%{+YYYY.MM.dd}"
  }
}

```

Sorry about the long post. Any suggestions about how I can debug the error?

Thanks

---

<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 30, 2020, 7:27am UTC](https://discuss.elastic.co/t/logstash-gives-error-error-address-already-in-use-when-ingesting-filebeat-with-two-inputs/226168/2 "2020-04-30T07:27:33Z")

</div>

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