# Logstash mongodb output plugin fails to authenticate

**URL:** <https://discuss.elastic.co/t/logstash-mongodb-output-plugin-fails-to-authenticate/272014>\
**Category:** Logstash\
**Created:** [May 3, 2021, 6:09pm UTC](https://discuss.elastic.co/t/logstash-mongodb-output-plugin-fails-to-authenticate/272014 "2021-05-03T18:09:43Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![aaron-dsouza](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aaron-dsouza/32/88152_2.png) [@aaron-dsouza](https://discuss.elastic.co/u/aaron-dsouza)\
**Post date:** [May 3, 2021, 6:09pm UTC](https://discuss.elastic.co/t/logstash-mongodb-output-plugin-fails-to-authenticate/272014/1 "2021-05-03T18:09:43Z")

</div>

I'm using the logstash mongodb output plugin to write documents to Azure cosmos DB. I am facing the exact same issue as reported here [Logstash MongoDB Output Plugin - command insert requires authentication](https://discuss.elastic.co/t/logstash-mongodb-output-plugin-command-insert-requires-authentication/268265)  
Here is my configuration

```auto
mongodb {
       collection => "mycollection"
        database => "mydatabase"
        isodate => true
        uri => "mongodb://username:password@cosmos-
account.mongo.cosmos.azure.com:10255/?ssl=true&replicaSet=globaldb"
}

```

This is the error I get

```auto
<Mongo::Auth::Unauthorized: User username is not authorized to access .>

```

Is there some special way that the connection string for cosmos db should be mentioned?  
If I try to access this cosmos db instance using the mongo shell and a python script, it works fine. It only fails from logstash

---

<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:** [May 31, 2021, 6:10pm UTC](https://discuss.elastic.co/t/logstash-mongodb-output-plugin-fails-to-authenticate/272014/2 "2021-05-31T18:10:21Z")

</div>

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