# Error during account deletion

**URL:** <https://discuss.openedx.org/t/error-during-account-deletion/7101>\
**Category:** Site Operations Help\
**Tags:** tutor\
**Created:** [April 25, 2022, 12:51pm UTC](https://discuss.openedx.org/t/error-during-account-deletion/7101 "2022-04-25T12:51:26Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ShreehariVaasishta](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.openedx.org/shreeharivaasishta/32/3544_2.png) [@ShreehariVaasishta](https://discuss.openedx.org/u/ShreehariVaasishta)\
**Post date:** [April 25, 2022, 12:51pm UTC](https://discuss.openedx.org/t/error-during-account-deletion/7101/1 "2022-04-25T12:51:26Z")

</div>

Hello  
I am getting an error while im trying to delete an account in self-hosted Open Edx. The user account I’m trying to delete is a superuser.  
I have deployed using tutor and am using the latest version.  
I have attached the error traceback below.

```auto
lms_1 | 2022-04-25 12:41:23,409 ERROR 7 [openedx.core.djangoapps.user_api.accounts.views] [user 8] [ip 124.123.80.200] views.py:573 - 500 error deactivating account Default state does not exist! Populate retirement states to retire users.
lms_1 | Traceback (most recent call last):
lms_1 | File "/openedx/edx-platform/./openedx/core/djangoapps/user_api/models.py", line 342, in create_retirement
lms_1 | pending = RetirementState.objects.all().order_by('state_execution_order')[0]
lms_1 | File "/openedx/venv/lib/python3.8/site-packages/django/db/models/query.py", line 318, in __getitem__
lms_1 | return qs._result_cache[0]
lms_1 | IndexError: list index out of range
lms_1 | 
lms_1 | During handling of the above exception, another exception occurred:
lms_1 | 
lms_1 | Traceback (most recent call last):
lms_1 | File "/openedx/edx-platform/./openedx/core/djangoapps/user_api/accounts/views.py", line 539, in post
lms_1 | create_retirement_request_and_deactivate_account(request.user)
lms_1 | File "/openedx/edx-platform/./openedx/core/djangoapps/user_api/accounts/utils.py", line 201, in create_retirement_request_and_deactivate_account
lms_1 | UserRetirementStatus.create_retirement(user)
lms_1 | File "/openedx/edx-platform/./openedx/core/djangoapps/user_api/models.py", line 344, in create_retirement
lms_1 | raise RetirementStateError('Default state does not exist! Populate retirement states to retire users.') # lint-amnesty, pylint: disable=raise-missing-from
lms_1 | openedx.core.djangoapps.user_api.models.RetirementStateError: Default state does not exist! Populate retirement states to retire users.
lms_1 | 2022-04-25 12:41:23,459 ERROR 7 [django.request] [user None] [ip None] log.py:224 - Internal Server Error: /api/user/v1/accounts/deactivate_logout/
caddy_1 |

```

---

<div class="post-metadata">

**Author:** ![uetuluk](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.openedx.org/uetuluk/32/3015_2.png) [@uetuluk](https://discuss.openedx.org/u/uetuluk)\
**Post date:** [April 26, 2022, 3:49am UTC](https://discuss.openedx.org/t/error-during-account-deletion/7101/2 "2022-04-26T03:49:13Z")

</div>

I also encountered this problem before, but I never fully implemented a solution.

I believe the key to the solution lies in this line.

> [@ShreehariVaasishta](#):
>
> `openedx.core.djangoapps.user_api.models.RetirementStateError: Default state does not exist! Populate retirement states to retire users.`

You can take a look at this guide to populate this `RETIREMENT_STATES` dictionary.

[https://edx.readthedocs.io/projects/edx-installing-configuring-and-running/en/latest/configuration/user\_retire/service\_setup.html](https://edx.readthedocs.io/projects/edx-installing-configuring-and-running/en/latest/configuration/user_retire/service_setup.html)

---

<div class="post-metadata">

**Author:** ![ShreehariVaasishta](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.openedx.org/shreeharivaasishta/32/3544_2.png) [@ShreehariVaasishta](https://discuss.openedx.org/u/ShreehariVaasishta)\
**Post date:** [April 26, 2022, 4:10am UTC](https://discuss.openedx.org/t/error-during-account-deletion/7101/3 "2022-04-26T04:10:57Z")

</div>

Thanks for sharing the specific doc link @uetuluk and pointing out the exact cause of the issue.

---

<div class="post-metadata">

**Author:** ![abstract-technology](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.openedx.org/abstract-technology/32/8931_2.png) [@abstract-technology](https://discuss.openedx.org/u/abstract-technology)\
**Post date:** [May 2, 2022, 2:24pm UTC](https://discuss.openedx.org/t/error-during-account-deletion/7101/4 "2022-05-02T14:24:18Z")

</div>

@uetuluk It’s not always easy to delete users, caused by many dependencies in the system. A quick and immediate help can be found into the Django panel.

Just disable the user: as active, as staff and as superusers member. The user can not have access any more.

---

<div class="post-metadata">

**Author:** ![ShreehariVaasishta](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.openedx.org/shreeharivaasishta/32/3544_2.png) [@ShreehariVaasishta](https://discuss.openedx.org/u/ShreehariVaasishta)\
**Post date:** [May 2, 2022, 4:09pm UTC](https://discuss.openedx.org/t/error-during-account-deletion/7101/5 "2022-05-02T16:09:54Z")

</div>

Got it, will do the same.  
Thank you @abstract-technology.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex020/uploads/openedx/original/2X/e/e0015f89e879bc75925b71fd11133ab15fe98297.png) [@system](https://discuss.openedx.org/u/system)\
**Post date:** [July 31, 2022, 4:10pm UTC](https://discuss.openedx.org/t/error-during-account-deletion/7101/6 "2022-07-31T16:10:50Z")

</div>

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