# Error When Deleting User Using mmctl

**URL:** <https://forum.mattermost.com/t/error-when-deleting-user-using-mmctl/10847>\
**Category:** Troubleshooting\
**Created:** [December 3, 2020, 8:45pm UTC](https://forum.mattermost.com/t/error-when-deleting-user-using-mmctl/10847 "2020-12-03T20:45:02Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ahmaddanial](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/ahmaddanial/32/2938_2.png) [@ahmaddanial](https://forum.mattermost.com/u/ahmaddanial)\
**Post date:** [December 3, 2020, 8:45pm UTC](https://forum.mattermost.com/t/error-when-deleting-user-using-mmctl/10847/1 "2020-12-03T20:45:02Z")

</div>

**Problem**  
Attempting to delete user via [mmctl user delete](https://docs.mattermost.com/administration/mmctl-cli-tool.html#mmctl-user-delete) fails with an error.

**Environment**  
Mattermost Server with [mmctl](https://docs.mattermost.com/administration/mmctl-cli-tool.html) installed.

**Diagnosis**

```auto
ahmaddanial@mattermost:/opt/mattermost$ mmctl user delete ahmad.danial@mattermost.com
WARNING: server version 5.29.0.5.29.0.45a60588b1ed9e0018bed1e1377071b9.true doesn't match mmctl version 5.28.0
Have you performed a database backup? (YES/NO):
YES
Are you sure you want to delete the users specified? All data will be permanently deleted? (YES/NO):
YES
Unable to delete user 'ahmad.danial' error: : Permanent user deletion feature is not enabled. Please contact your System Administrator.,

```

**Cause**  
The [EnableAPIUserDeletion](https://docs.mattermost.com/administration/config-settings.html?highlight=config%20settings#enable-api-user-deletion) is set to `false`.

**Resolution**  
Make the change to the parameter via `config.json` to set it to `true` before running the `mmctl user delete` command again:

```auto
ahmaddanial@mattermost:/opt/mattermost$ mmctl user delete ahmad.danial@mattermost.com
WARNING: server version 5.29.0.5.29.0.45a60588b1ed9e0018bed1e1377071b9.true doesn't match mmctl version 5.28.0
Have you performed a database backup? (YES/NO):
YES
Are you sure you want to delete the users specified? All data will be permanently deleted? (YES/NO):
YES
Deleted user 'ahmad.danial'

```

---

<div class="post-metadata">

**Author:** ![GuidoD](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/guidod/32/6715_2.png) [@GuidoD](https://forum.mattermost.com/u/GuidoD)\
**Post date:** [December 4, 2020, 2:14pm UTC](https://forum.mattermost.com/t/error-when-deleting-user-using-mmctl/10847/2 "2020-12-04T14:14:24Z")

</div>

but even when it is set to true, this does only work in a standard installation and not inside a docker container installation with PostgreSQL database:

root@abc:/var/xyz/mattermost# docker-compose exec app sh  
~ $ mmctl user delete u78yrxgftpg89bwijmy6ez98we --confirm --local  
Unable to delete user ‘username’ error: : Konnte die zu löschenden Nachrichten für den Benutzer nicht auswählen.,  
(Could not select the messages for the user to delete)

---

<div class="post-metadata">

**Author:** ![hkpanchani](https://avatars.discourse-cdn.com/v4/letter/h/e495f1/32.png) [@hkpanchani](https://forum.mattermost.com/u/hkpanchani)\
**Post date:** [February 4, 2021, 3:02pm UTC](https://forum.mattermost.com/t/error-when-deleting-user-using-mmctl/10847/3 "2021-02-04T15:02:51Z")

</div>

I have enabled [EnableAPIUserDeletion] still it is showing the same…I have installed omni installation… After changing config file do i need to change anything?? I tried restarting it and reconfigure it but still showing same error…

---

<div class="post-metadata">

**Author:** ![mgdelacroix](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/mgdelacroix/32/4081_2.png) [@mgdelacroix](https://forum.mattermost.com/u/mgdelacroix)\
**Post date:** [February 4, 2021, 3:29pm UTC](https://forum.mattermost.com/t/error-when-deleting-user-using-mmctl/10847/4 "2021-02-04T15:29:20Z")

</div>

Please take into account that Omnibus [uses configuration in the database](https://docs.mattermost.com/install/mattermost-omnibus.html#configuring-mattermost-omnibus), so changing the `config.json` file has no effect on the application’s configuration.

Can you try to update the configuration running

```auto
mmctl config set ServiceSettings.EnableAPIUserDeletion true --local

```

and then try to delete a user again?

---

<div class="post-metadata">

**Author:** ![hkpanchani](https://avatars.discourse-cdn.com/v4/letter/h/e495f1/32.png) [@hkpanchani](https://forum.mattermost.com/u/hkpanchani)\
**Post date:** [February 4, 2021, 3:34pm UTC](https://forum.mattermost.com/t/error-when-deleting-user-using-mmctl/10847/6 "2021-02-04T15:34:19Z")

</div>

Thank you This worked

---

<div class="post-metadata">

**Author:** ![jimthedj65](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/jimthedj65/32/4850_2.png) [@jimthedj65](https://forum.mattermost.com/u/jimthedj65)\
**Post date:** [May 30, 2021, 9:42pm UTC](https://forum.mattermost.com/t/error-when-deleting-user-using-mmctl/10847/7 "2021-05-30T21:42:11Z")

</div>

This was hard to find, I would like to put forward that it is published in the official documentation. Worked for me on the latest build.
