nativeInstallerdiscourse

Modify the default administrator email address

Before running the commands shown on this page, you should load the Bitnami stack environment by executing the installdir/use_APPNAME script (Linux and MacOS) or by clicking the shortcut in the Start Menu under “Start -> Bitnami APPNAME Stack -> Application console” (Windows). On OS X VMs, the installation directory is /opt/bitnami and OS X VM users can click the “Open Terminal” button to run commands. Learn more about the Bitnami stack environment and about OS X VMs.

NOTE: The Approach A sections referred to below do not apply to Bitnami native installers. Users of Bitnami native installers should refer only to the Approach B sections.

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:

  • Load the Bitnami console (Windows, Linux or macOS installers) or log in to the virtual machine console (OS X VM).

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

    • Approach A (Bitnami installations using system packages):

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

        $ cd installdir/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