# Failed to create client for go-elasticsearch

**URL:** https://discuss.elastic.co/t/failed-to-create-client-for-go-elasticsearch/348848
**Category:** Elasticsearch
**Created:** [December 8, 2023, 2:27am UTC](https://discuss.elastic.co/t/failed-to-create-client-for-go-elasticsearch/348848 "2023-12-08T02:27:00Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Bosees](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bosees/32/128732_2.png) [@Bosees](https://discuss.elastic.co/u/Bosees)
#### Post date: [December 8, 2023, 2:27am UTC](https://discuss.elastic.co/t/failed-to-create-client-for-go-elasticsearch/348848/1 "2023-12-08T02:27:00Z")

</div>

I'm trying to create a client using go-elasticsearch with a viewer permission user who can only play a read role. The problem is that I'm getting a 403 error. Here is the corresponding error log

```auto
"type":"security_exception","reason":"action [cluster:monitor/main] is unauthorized for user [readonly] with effective roles [viewer], this action is granted by the cluster privileges [monitor,manage,all]"

```

This does not happen in JS-elasticsearch.  
Is the action related to monitor included by default in Go-elasticsearch? How can I turn it off? I don't see it when I look at the interface of the Config type.

This is my current connection code block.

```auto
cfg := elasticsearch.Config{
		Addresses: []string{
			esConfig.Host,
		},
		Username: esConfig.User,
		Password: esConfig.Password,
	}

```

I don't want to just grant permissions, I want to start with just viewer permissions like JS-Elasticsearch works.

---

<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: [January 5, 2024, 2:27am UTC](https://discuss.elastic.co/t/failed-to-create-client-for-go-elasticsearch/348848/2 "2024-01-05T02:27:48Z")

</div>

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