bchdiscourse

Modify the default administrator email address

NOTE: We are in the process of modifying the file structure and configuration for many Bitnami stacks. On account of these changes, the file paths stated in this guide may change depending on whether your Bitnami stack uses native Linux system packages (Approach A), or if it is a self-contained installation (Approach B). To identify your Bitnami installation type and what approach to follow, run the command below:

 $ test ! -f "/opt/bitnami/common/bin/openssl" && echo "Approach A: Using system packages." || echo "Approach B: Self-contained installation."

The output of the command indicates which approach (A or B) is used by the installation, and will allow you to identify the paths, configuration and commands to use in this guide. Refer to the FAQ for more information on these changes.

During the deployment of Discourse, the administrator email used by default is user@example.com. As the administrator user, you most likely want to change it to your personal email address.

Changing the default administrator email requires an email verification from the current user@example.com email address, which is not possible from the Discourse settings panel. To do so, you need to perform some queries in the PostgreSQL database.

Follow the steps below in order to change the default administrator email in Discourse:

  • Log in to the server console. Learn how to connect to the server through SSH.

  • Enter the Rails console. Depending on your installation type, run the commands below:

    • Approach A (Bitnami installations using system packages):

        $ cd /opt/bitnami/discourse
        $ RAILS_ENV=production bundle exec rails c
      
    • Approach B (Self-contained Bitnami installations):

        $ cd /opt/bitnami/apps/discourse/htdocs/
        $ sudo RAILS_ENV=production bundle exec rails c
      

    A new prompt should appear, as shown below:

      irb(main):001:0>
    
  • At the prompt, run the following commands to change the email address of the default user account to a new email address. Replace the EMAIL_ADDRESS placeholder in the commands below with your desired email address:

      u = User.find_by_username("user")
      u.email = "YOUR_NEW_EMAIL_ADDRESS"
      u.email_tokens.create(email: u.email)
      u.activate
      u.save!
    

The default administrator email address will be changed. You can verify the changes in your application admin panel:

  • In the top right menu, click the “Hamburger” button and select the “Admin” option.

    Discourse admin panel

  • Navigate to the “Users” section. You can check that the email associated with the admin user has changed:

    Discourse default admin email changed

Last modification June 16, 2021