# Got permission denied while trying to connect to the Docker daemon socket

**URL:** <https://community.influxdata.com/t/got-permission-denied-while-trying-to-connect-to-the-docker-daemon-socket/23353>\
**Category:** Telegraf\
**Tags:** telegraf, docker\
**Created:** [January 13, 2022, 8:23am UTC](https://community.influxdata.com/t/got-permission-denied-while-trying-to-connect-to-the-docker-daemon-socket/23353 "2022-01-13T08:23:14Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aritra666B](https://avatars.discourse-cdn.com/v4/letter/a/8491ac/32.png) [@Aritra666B](https://community.influxdata.com/u/Aritra666B)\
**Post date:** [January 13, 2022, 8:23am UTC](https://community.influxdata.com/t/got-permission-denied-while-trying-to-connect-to-the-docker-daemon-socket/23353/1 "2022-01-13T08:23:14Z")

</div>

When we first started using the v2 & telegraf input plugins, there was no problem, but restarting the system suddenly the getting this error ([inputs.docker] Error in plugin: Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get “http://%2Fvar%2Frun%2Fdocker.sock/v1.21/containers/json?filters=%7B%22status%22%3A%5B%22running%22%5D%7D&limit=0”: dial unix /var/run/docker.sock: connect: permission denied) and now the InfluxDB 2.0 OSS Metrics & Docker data dashboards are not working… In the database we can see the respective tables are created but they are all empty.

How can we solve this error? Do the system need internet connection for these to work?

---

<div class="post-metadata">

**Author:** ![Jay\_Clifford](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/jay_clifford/32/8287_2.png) [@Jay\_Clifford](https://community.influxdata.com/u/Jay_Clifford)\
**Post date:** [January 13, 2022, 10:52am UTC](https://community.influxdata.com/t/got-permission-denied-while-trying-to-connect-to-the-docker-daemon-socket/23353/2 "2022-01-13T10:52:11Z")

</div>

Hi @Aritra666B,  
Can you trying running:

```auto
sudo usermod -aG docker telegraf

```

Then restart the telegraf service?

---

<div class="post-metadata">

**Author:** ![Aritra666B](https://avatars.discourse-cdn.com/v4/letter/a/8491ac/32.png) [@Aritra666B](https://community.influxdata.com/u/Aritra666B)\
**Post date:** [January 17, 2022, 7:10am UTC](https://community.influxdata.com/t/got-permission-denied-while-trying-to-connect-to-the-docker-daemon-socket/23353/3 "2022-01-17T07:10:27Z")

</div>

Hi @Jay_Clifford ,

I tried it but didn’t work. In the given command I only replaced telegraf with my user.

still get this.  
[inputs.docker] Error in plugin: Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get “http://%2Fvar%2Frun%2Fdocker.sock/v1.21/containers/json?filters=%7B%22status%22%3A%5B%22running%22%5D%7D&limit=0”: dial unix /var/run/docker.sock: connect: permission denied

---

<div class="post-metadata">

**Author:** ![Jay\_Clifford](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/jay_clifford/32/8287_2.png) [@Jay\_Clifford](https://community.influxdata.com/u/Jay_Clifford)\
**Post date:** [January 17, 2022, 10:45am UTC](https://community.influxdata.com/t/got-permission-denied-while-trying-to-connect-to-the-docker-daemon-socket/23353/4 "2022-01-17T10:45:58Z")

</div>

Hi @Aritra666B,  
Telegraf generates its own user. You need to add Telegraf to the docker group. Please run the above command again as intended 🙂.

---

<div class="post-metadata">

**Author:** ![Aritra666B](https://avatars.discourse-cdn.com/v4/letter/a/8491ac/32.png) [@Aritra666B](https://community.influxdata.com/u/Aritra666B)\
**Post date:** [January 17, 2022, 11:11am UTC](https://community.influxdata.com/t/got-permission-denied-while-trying-to-connect-to-the-docker-daemon-socket/23353/5 "2022-01-17T11:11:27Z")

</div>

Hi @Jay_Clifford ,

If I run that command it gives me error → usermod: user ‘telegraf’ does not exist.

Do I have to create any group at first with name ‘telegraf’ ?

---

<div class="post-metadata">

**Author:** ![jpowers](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/jpowers/32/8569_2.png) [@jpowers](https://community.influxdata.com/u/jpowers)\
**Post date:** [January 19, 2022, 12:45am UTC](https://community.influxdata.com/t/got-permission-denied-while-trying-to-connect-to-the-docker-daemon-socket/23353/6 "2022-01-19T00:45:44Z")

</div>

Hi,

How did you install Telegraf? Deb? RPM? is this running in a docker container?

Could you also run `ls -l /var/run/docker.sock` and provide the output please!

Thanks!

---

<div class="post-metadata">

**Author:** ![Aritra666B](https://avatars.discourse-cdn.com/v4/letter/a/8491ac/32.png) [@Aritra666B](https://community.influxdata.com/u/Aritra666B)\
**Post date:** [January 19, 2022, 4:52am UTC](https://community.influxdata.com/t/got-permission-denied-while-trying-to-connect-to-the-docker-daemon-socket/23353/7 "2022-01-19T04:52:59Z")

</div>

I installed telegraf directly from docker site. : sudo docker pull telegraf. Normaly telegraf is working fine, I mena it’s inserting data to influxdb uisng opcua but the internal docker & influxdb tables are all empty.

After running your command got the following msg:  
ubuntu@ubuntu:~$ ls -l /var/run/docker.sock  
srw-rwxrw- 1 root docker 0 Jan 10 07:36 /var/run/docker.sock

---

<div class="post-metadata">

**Author:** ![Jay\_Clifford](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/jay_clifford/32/8287_2.png) [@Jay\_Clifford](https://community.influxdata.com/u/Jay_Clifford)\
**Post date:** [January 19, 2022, 9:34am UTC](https://community.influxdata.com/t/got-permission-denied-while-trying-to-connect-to-the-docker-daemon-socket/23353/8 "2022-01-19T09:34:34Z")

</div>

Hi @Aritra666B,  
Ah, my apologies I should have asked if you were using docker. Can you send along your docker-compose?

Did you mount the socket to the container? Here is the raw docker run command:

```auto
 docker run -d --name=telegraf \
      --net=influxdb \
      -v /var/run/docker.sock:/var/run/docker.sock \
      -v $PWD/telegraf.conf:/etc/telegraf/telegraf.conf:ro \
      telegraf

```

---

<div class="post-metadata">

**Author:** ![Aritra666B](https://avatars.discourse-cdn.com/v4/letter/a/8491ac/32.png) [@Aritra666B](https://community.influxdata.com/u/Aritra666B)\
**Post date:** [January 19, 2022, 10:40am UTC](https://community.influxdata.com/t/got-permission-denied-while-trying-to-connect-to-the-docker-daemon-socket/23353/9 "2022-01-19T10:40:58Z")

</div>

Hi @Jay_Clifford ,

Thanks for the help, now we can get data in the internal tables as well.

---

<div class="post-metadata">

**Author:** ![mirino](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/mirino/32/11144_2.png) [@mirino](https://community.influxdata.com/u/mirino)\
**Post date:** [June 2, 2023, 12:31pm UTC](https://community.influxdata.com/t/got-permission-denied-while-trying-to-connect-to-the-docker-daemon-socket/23353/10 "2023-06-02T12:31:41Z")

</div>

sudo usermod -aG docker \_telegraf

Thank you for your help.

“Ubuntu 22.04.2 LTS” , Telegraf 1.21.4+ds1-0ubuntu2, Docker version 24.0.2, build cb74dfc
