# Logstash-output-mongodb - bad file descriptor

**URL:** <https://discuss.elastic.co/t/logstash-output-mongodb-bad-file-descriptor/108542>\
**Category:** Logstash\
**Created:** [November 21, 2017, 10:06am UTC](https://discuss.elastic.co/t/logstash-output-mongodb-bad-file-descriptor/108542 "2017-11-21T10:06:48Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![blueren](https://avatars.discourse-cdn.com/v4/letter/b/ecae2f/32.png) [@blueren](https://discuss.elastic.co/u/blueren)\
**Post date:** [November 21, 2017, 10:06am UTC](https://discuss.elastic.co/t/logstash-output-mongodb-bad-file-descriptor/108542/1 "2017-11-21T10:06:48Z")

</div>

I have my logstash config as below:

```
output {
    if [type] == "netflow" {
        elasticsearch {
            hosts => ["${ELASTIFLOW_ES_HOST:127.0.0.1:9200}"]
            user => "${ELASTIFLOW_ES_USER:elastic}"
            password => "${ELASTIFLOW_ES_PASSWD:changeme}"
            index => "netflow-%{+YYYY.MM.dd}"
            template => "${ELASTIFLOW_TEMPLATE_PATH:/etc/logstash/templates}/netflow.template.json"
            template_name => "netflow"
            template_overwrite => "true"
        }
        mongodb {
            uri => "mongodb://localhost:3001"
            database => "meteor"
            collection => "logstash_%{type}"
            isodate => true
        }
    }

}

```

Since I'm using a meteor's built in mongodb, the db goes offline if the meteor app gets killed. Once the meteor app is back online, logstash continues to complain with the below message, until I restart logstash.

```
[2017-11-21T15:34:12,447][DEBUG][logstash.pipeline] Pushing flush onto pipeline
[2017-11-21T15:34:14,195][DEBUG][logstash.outputs.mongodb] MONGODB | COMMAND | namespace=admin.$cmd selector={:ismaster=>1} flags=[] limit=-1 skip=0 project=nil | runtime: 0.9999ms
[2017-11-21T15:34:14,195][DEBUG][logstash.outputs.mongodb] MONGODB | Bad file descriptor - Bad file descriptor | runtime: 0.0000ms
[2017-11-21T15:34:14,695][DEBUG][logstash.outputs.mongodb] MONGODB | COMMAND | namespace=admin.$cmd selector={:ismaster=>1} flags=[] limit=-1 skip=0 project=nil | runtime: 1.9999ms
[2017-11-21T15:34:14,695][DEBUG][logstash.outputs.mongodb] MONGODB | Bad file descriptor - Bad file descriptor | runtime: 0.0000ms
[2017-11-21T15:34:15,195][DEBUG][logstash.outputs.mongodb] MONGODB | COMMAND | namespace=admin.$cmd selector={:ismaster=>1} flags=[] limit=-1 skip=0 project=nil | runtime: 1.9999ms
[2017-11-21T15:34:15,195][DEBUG][logstash.outputs.mongodb] MONGODB | Bad file descriptor - Bad file descriptor | runtime: 0.0000ms

```

How do I remedy this? Do I necessarily need to restart logstash each time my mongodb restarts?

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:** [December 19, 2017, 10:06am UTC](https://discuss.elastic.co/t/logstash-output-mongodb-bad-file-descriptor/108542/2 "2017-12-19T10:06:51Z")

</div>

Closed on December 19, 2017, 10:06am UTC

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