# I can't change my admin user email

**URL:** https://meta.discourse.org/t/i-cant-change-my-admin-user-email/237978
**Category:** Support
**Created:** [September 2, 2022, 9:09pm UTC](https://meta.discourse.org/t/i-cant-change-my-admin-user-email/237978 "2022-09-02T21:09:31Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![danielabc](https://avatars.discourse-cdn.com/v4/letter/d/b9e5f3/32.png) [@danielabc](https://meta.discourse.org/u/danielabc)
#### Post date: [September 2, 2022, 9:09pm UTC](https://meta.discourse.org/t/i-cant-change-my-admin-user-email/237978/1 "2022-09-02T21:09:31Z")

</div>

So guys, I have a forum, and on that forum I am the only admin and owner! It turns out that when I made this site I used an email called REDACTED this email I used through the cpanel of TMD hosting, it happened that I no longer use the services of tmd hosting and went to the digital ocean and I even forgot that my adm’s email was this, I didn’t change it! It turns out that now I went to give the administration to another account of mine on the forum and the forum asks me to enter my account REDACTED and confirm that I want to give the admin to another account, but I can no longer access the cpanel of tmd hosting to access REDACTED, what do I do?

[image]

---

<div class="post-metadata">

### Author: ![danielabc](https://avatars.discourse-cdn.com/v4/letter/d/b9e5f3/32.png) [@danielabc](https://meta.discourse.org/u/danielabc)
#### Post date: [September 2, 2022, 9:14pm UTC](https://meta.discourse.org/t/i-cant-change-my-admin-user-email/237978/2 "2022-09-02T21:14:40Z")

</div>

I contacted TMD hosting and was informed that my email REDACTED no longer exists, and only by purchasing a new server I can activate it, but what about my forum admin? will you be stuck forever in this email REDACTED ? there’s no way I can change it even though I have the password for all the things on my own forum?

---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [September 2, 2022, 9:37pm UTC](https://meta.discourse.org/t/i-cant-change-my-admin-user-email/237978/3 "2022-09-02T21:37:29Z")

</div>

You can change your admin email through the rails console with this handy guide: 👍

> [@Change staff email address from console](https://meta.discourse.org/t/change-staff-email-address-from-console/42062):
>
> bookmark This guide describes how to change a staff member’s email address from the console using the Rails console. It applies to situations where an administrator needs to update an email without confirmation from the old address. person_raising_hand Required user level: System Administrator warning Console access required In Discourse, for enhanced security, staff members must confirm changes to their email addresses from both the new and old email addresses. However, this creates…

---

<div class="post-metadata">

### Author: ![danielabc](https://avatars.discourse-cdn.com/v4/letter/d/b9e5f3/32.png) [@danielabc](https://meta.discourse.org/u/danielabc)
#### Post date: [September 2, 2022, 10:26pm UTC](https://meta.discourse.org/t/i-cant-change-my-admin-user-email/237978/4 "2022-09-02T22:26:47Z")

</div>

thanks for answering me, but now another problem has arisen that even following some tutorials I can’t find! How do I see the user ID?

[image]

---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [September 2, 2022, 10:34pm UTC](https://meta.discourse.org/t/i-cant-change-my-admin-user-email/237978/5 "2022-09-02T22:34:21Z")

</div>

There’s a way to do it in that guide using your username instead, which might be easier?

---

<div class="post-metadata">

### Author: ![danielabc](https://avatars.discourse-cdn.com/v4/letter/d/b9e5f3/32.png) [@danielabc](https://meta.discourse.org/u/danielabc)
#### Post date: [September 2, 2022, 10:39pm UTC](https://meta.discourse.org/t/i-cant-change-my-admin-user-email/237978/6 "2022-09-02T22:39:31Z")

</div>

```plaintext
root@ForumPandex:/var/discourse# u = User.find_by_username("dex")
-bash: syntax error near unexpected token `('
root@ForumPandex:/var/discourse#

```

i use that comand, but appear it, how fix?

---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [September 2, 2022, 10:47pm UTC](https://meta.discourse.org/t/i-cant-change-my-admin-user-email/237978/7 "2022-09-02T22:47:42Z")

</div>

You need to follow the guide more closely. You’re missing the steps where you **Enter the container** , and then **Access Rails Console** before running the next commands.

However, I would also suggest taking a backup of your site before diving any deeper. The step by step in the guide certainly makes it easier, but if you’re unfamiliar with the rails console accidents can happen. You don’t want to mess anything up without having a recent backup handy. 👍 🤞

---

<div class="post-metadata">

### Author: ![danielabc](https://avatars.discourse-cdn.com/v4/letter/d/b9e5f3/32.png) [@danielabc](https://meta.discourse.org/u/danielabc)
#### Post date: [September 2, 2022, 10:53pm UTC](https://meta.discourse.org/t/i-cant-change-my-admin-user-email/237978/8 "2022-09-02T22:53:01Z")

</div>

what is bits? i dont know

---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [September 2, 2022, 11:00pm UTC](https://meta.discourse.org/t/i-cant-change-my-admin-user-email/237978/9 "2022-09-02T23:00:30Z")

</div>

I’ve given the language in my post above a tweak. Hopefully that’s clearer now. 👍

If this is still not making sense, I would take a step back and maybe think about getting some help in the #Marketplace.

---

<div class="post-metadata">

### Author: ![danielabc](https://avatars.discourse-cdn.com/v4/letter/d/b9e5f3/32.png) [@danielabc](https://meta.discourse.org/u/danielabc)
#### Post date: [September 2, 2022, 11:03pm UTC](https://meta.discourse.org/t/i-cant-change-my-admin-user-email/237978/10 "2022-09-02T23:03:46Z")

</div>

I’m using Google Translate, I can’t understand what you said, maybe it’s some wrong translation or out of google context!

But what I don’t understand is that I’m following the step by step correctly, I don’t know why this appears:

-bash: syntax error near unexpected token `(’

What is market place?

---

<div class="post-metadata">

### Author: ![danielabc](https://avatars.discourse-cdn.com/v4/letter/d/b9e5f3/32.png) [@danielabc](https://meta.discourse.org/u/danielabc)
#### Post date: [September 2, 2022, 11:17pm UTC](https://meta.discourse.org/t/i-cant-change-my-admin-user-email/237978/11 "2022-09-02T23:17:16Z")

</div>

I restarted my computer, and the error stopped! But now another error came, in the step of putting the email, `u.email = "REDACTED"` it looks like this

invalid mark letter (press return)

---

<div class="post-metadata">

### Author: ![danielabc](https://avatars.discourse-cdn.com/v4/letter/d/b9e5f3/32.png) [@danielabc](https://meta.discourse.org/u/danielabc)
#### Post date: [September 2, 2022, 11:20pm UTC](https://meta.discourse.org/t/i-cant-change-my-admin-user-email/237978/12 "2022-09-02T23:20:18Z")

</div>

in the step of putting the email, `u.email = "REDACTED"` it looks like this

invalid mark letter (press return)

how i fix it?

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [September 3, 2022, 12:22am UTC](https://meta.discourse.org/t/i-cant-change-my-admin-user-email/237978/13 "2022-09-03T00:22:58Z")

</div>

I don’t understand what is wrong from your description. Make sure that there is no trailing space after the email address. But I recommend creating a new admin user with

```
   rake admin:create

```

Then remove admin and moderator privileges from the user whose address you want to update. Then you can make that user an admin again.

---

<div class="post-metadata">

### Author: ![danielabc](https://avatars.discourse-cdn.com/v4/letter/d/b9e5f3/32.png) [@danielabc](https://meta.discourse.org/u/danielabc)
#### Post date: [September 3, 2022, 4:12am UTC](https://meta.discourse.org/t/i-cant-change-my-admin-user-email/237978/14 "2022-09-03T04:12:22Z")

</div>

I put this before which step? Anyway, now it’s showing up

> root@ForumPandex:~# cd /var/discourse  
> root@ForumPandex:/var/discourse# ./launcher enter app  
> x86\_64 arch detected.  
> WARNING: containers/app.yml file is world-readable. You can secure this file by running: chmod o-rwx containers/app.yml  
> root@ForumPandex-app:/var/www/discourse#

---

<div class="post-metadata">

### Author: ![danielabc](https://avatars.discourse-cdn.com/v4/letter/d/b9e5f3/32.png) [@danielabc](https://meta.discourse.org/u/danielabc)
#### Post date: [September 3, 2022, 4:33am UTC](https://meta.discourse.org/t/i-cant-change-my-admin-user-email/237978/15 "2022-09-03T04:33:43Z")

</div>

```plaintext
root@ForumPandex:~# cd /var/discourse
root@ForumPandex:/var/discourse# ./launcher enter app
x86_64 arch detected.
WARNING: containers/app.yml file is world-readable. You can secure this file by running: chmod o-rwx containers/app.yml
root@ForumPandex-app:/var/www/discourse# rails c
[1] pry(main)> u = User.find_by_username "=dex="
=> nil
[2] pry(main)> e.email = "EMAIL"
NameError: undefined local variable or method `e' for main:Object
from (pry):2:in ` __pry__'
[3] pry(main)> u.email = "EMAIL"
NoMethodError: undefined method `email=' for nil:NilClass
from (pry):3:in ` __pry__'
[4] pry(main)> u.email_tokens.create(email: u.email)
NoMethodError: undefined method `email_tokens' for nil:NilClass
from (pry):4:in ` __pry__'
[5] pry(main)> u.save!
NoMethodError: undefined method `save!' for nil:NilClass
from (pry):5:in ` __pry__'
[6] pry(main)>

```

---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [September 3, 2022, 5:13am UTC](https://meta.discourse.org/t/i-cant-change-my-admin-user-email/237978/16 "2022-09-03T05:13:34Z")

</div>

I’ve moved your posts over to here to keep all the information of the issue in one place so people can find it easier to help you. 👍

Just to note as well, you should consider not revealing your admin email itself in your help requests. One of our community experts is helpfully editing it out of your posts as you go, but it would be easier if it was not included. 🙂

It seems you’ve figured out how to get to the rails console. 👍 But it looks like you’ve included the placeholder `=` signs when inputting the username. You should enter the username without them.

* * *

Though @pfaffman has suggested an alternative method if this one is proving too tricky:

> [@pfaffman](#):
>
> But I recommend creating a new admin user with
> 
> ```plaintext
> rake admin:create
> 
> ```
> 
> Then remove admin and moderator privileges from the user whose address you want to update. Then you can make that user an admin again.

If you create a second admin it would allow you to remove the admin privileges from the account you want to change the email address of, and remove the security restriction of needing email confirmation from the old email address. You can then change the email of the original account using the new admin, before regranting admin privileges again.

You can find more info about the create admin rake task in [Create an admin account from the console](https://meta.discourse.org/t/create-admin-account-from-console/17274)

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [September 3, 2022, 9:59am UTC](https://meta.discourse.org/t/i-cant-change-my-admin-user-email/237978/17 "2022-09-03T09:59:15Z")

</div>

You didn’t enter the username into the blank fields in the topic that has the code in it so what is should be the username is instead the text that is the place holder.

```
u = User.find_by_username "=dex="

```

Should be.

```
 u = User.find_by_username "dex"

```

If dex is the username. The fact that it returns nil rather than the user record is your indication that you don’t have a user record. Since you don’t understand those basics I really recommend creating a new user as suggested earlier. That will allow you to work with more familiar tools.

---

<div class="post-metadata">

### Author: ![danielabc](https://avatars.discourse-cdn.com/v4/letter/d/b9e5f3/32.png) [@danielabc](https://meta.discourse.org/u/danielabc)
#### Post date: [September 3, 2022, 4:28pm UTC](https://meta.discourse.org/t/i-cant-change-my-admin-user-email/237978/18 "2022-09-03T16:28:53Z")

</div>

otherwise it just gave me problems, so I did this one to create a new adm and it worked, with the new adm I deleted the old one, thanks for everything!

[image]

---

<div class="post-metadata">

### Author: ![danielabc](https://avatars.discourse-cdn.com/v4/letter/d/b9e5f3/32.png) [@danielabc](https://meta.discourse.org/u/danielabc)
#### Post date: [September 3, 2022, 4:29pm UTC](https://meta.discourse.org/t/i-cant-change-my-admin-user-email/237978/19 "2022-09-03T16:29:27Z")

</div>

thanks for the help, i’m very grateful for you! a kiss from Brazil

[image]

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [October 3, 2022, 4:30pm UTC](https://meta.discourse.org/t/i-cant-change-my-admin-user-email/237978/20 "2022-10-03T16:30:06Z")

</div>

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