How to Install Mastodon on Ubuntu 22.04/20.04 Server

This tutorial is going to show you how to install Mastodon on Ubuntu 22.04/20.04 server. Mastodon is an open-source decentralized social network. It’s like Twitter, but decentralized. You can set up a Mastodon instance on your server and connect to other Mastodon instances.

Mastodon Features

  • Total data control. You can download all your posts and migrate to another instance.
  • Never worry about account termination by a central organization.
  • Each Mastodon instance can set its own rules.
  • 500 character limit per post.
  • Mobile-friendly, responsive web design. Users can read or post from laptop, tablet and phone.
  • 100% free open source. No paid commercial version with better or more complete features.
  • Official mobile apps for Mastodon are available for iOS and Android
  • And many more.

Mastodon is written with React.js and Ruby on Rails, using PostgreSQL as the back-end database management system.

Prerequisites

Here’s what you should prepare before setting up your own Mastodon instance.

1. A domain name. You need a domain name, so other people can access your Mastodon instance. I registered my domain name at NameCheap because the price is low and they give whois privacy protection free for life.

2. A server. To run Mastodon, you need a server with at least 2GB RAM. If you are looking for a virtual private server (VPS), I recommend Kamatera VPS, which features:

  • 30 days free trial.
  • Starts at $4/month (1GB RAM)
  • High-performance KVM-based VPS
  • 9 data centers around the world, including the United States, Canada, UK, Germany, The Netherlands, Hong Kong, and Isreal.
  • CPU and RAM hot-add. You can temporarily upgrade the server CPU and RAM for free without a reboot.

Follow the tutorial linked below to create your Linux VPS server at Kamatera.

3. SMTP Service. You need to use an SMTP server to send emails for account registration and various other notifications.  You can set up your own email server (which takes some time), or use a free SMTP relay service (easier)

Once the above requirements are met, follow the steps below to install Mastodon.

Step 1: Configure PostgreSQL Database Server

Log into your server via SSH. PostgreSQL is available in the default Ubuntu repository. However, the PostgreSQL team always strives to make performance improvements with every new version, so we will install the latest version of PostgreSQL from the upstream repository.

Add the upstream repository.

echo "deb [signed-by=/etc/apt/keyrings/postgresql.asc] http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" | sudo tee /etc/apt/sources.list.d/pgdg.list

Import the PostgreSQL public key.

sudo mkdir -p /etc/apt/keyrings/

wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo tee /etc/apt/keyrings/postgresql.asc

Update repository index and install PostgreSQL.

sudo apt update

sudo apt install -y postgresql postgresql-contrib

PostgreSQL database server will automatically start and listens on 127.0.0.1:5432, as can be seen with the following command.

sudo ss -lnpt | grep postgres

mastodon postgresql ubuntu

If you don’t see any output from the above command, it’s probably because PostgreSQL server isn’t running. You can start PostgreSQL server by issuing the following command.

sudo systemctl start postgresql

The postgres user is created on the OS during the installation process. It’s the super user for PostgreSQL database server. We can use sudo to switch to the postgres user and log into the PostgreSQL console.

sudo -u postgres -i psql

Create a database for Mastodon.

CREATE DATABASE mastodon;

Create a database user.

CREATE USER mastodon;

Set a password for this user.

ALTER USER mastodon WITH ENCRYPTED PASSWORD 'your_preferred_password';

Give this user permission to create database.

ALTER USER mastodon createdb;

Set this user as the owner of Mastodon database.

ALTER DATABASE mastodon OWNER TO mastodon;

Log out from the PostgreSQL console.

\q

postgresql create database for mastodon

Step 2: Install Ruby on Ubuntu 22.04/20.04

Mastodon requires Ruby 2.7+. Ubuntu 22.04/20.04 repository includes the ruby package, so run the following command to install it.

sudo apt install ruby ruby-dev

To check your Ruby version number, run

ruby -v

Sample output:

ruby 2.7.4p191 (2021-07-07 revision a21a3b7d23) [x86_64-linux-gnu]

Step 3: Download and Configure Mastodon

Create the mastodon user.

sudo adduser mastodon --system --group --disabled-login

Install the git tool.

sudo apt install git

Run the following command to clone the Mastodon code repository from Github.

git clone https://github.com/tootsuite/mastodon.git

Create the /var/www/ directory, if it’s not already created.

sudo mkdir -p /var/www/

Move the mastodon directory to /var/www/.

sudo mv mastodon/ /var/www/

Change the owner to mastodon.

sudo chown mastodon:mastodon /var/www/mastodon/ -R

Change directory and check out the latest stable release of Mastodon. You can go to the Github releases page to see the latest stable version. I’m now using v4.0.2.

cd /var/www/mastodon/

sudo -u mastodon git checkout v4.0.2

Install bundler: the Ruby dependency manager.

sudo gem install bundler

Install Node.js v16. (Mastodon isn’t compatible with Node.js v18 or v19).

curl -sL https://deb.nodesource.com/setup_16.x | sudo bash -

sudo apt install nodejs

Install Yarn, a Node.js package manager.

echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list

curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -

sudo apt update

sudo apt -y install yarn

Install required packages to compile source code.

sudo apt install redis-server optipng pngquant jhead jpegoptim gifsicle nodejs imagemagick ffmpeg libpq-dev libxml2-dev libxslt1-dev file g++ libprotobuf-dev protobuf-compiler pkg-config gcc autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm-dev libidn11-dev libicu-dev libjemalloc-dev

Then install dependency packages for Mastodon.

sudo -u mastodon bundle config deployment 'true'

sudo -u mastodon bundle config without 'development test'

sudo -u mastodon bundle install -j$(getconf _NPROCESSORS_ONLN)

Run the setup wizard.

sudo -u mastodon RAILS_ENV=production bundle exec rake mastodon:setup

First, it will ask you a series of questions.

  • Domain name: Choose a domain name to use for your Mastodon instance. For example, I use social.linuxbabe.com.
  • Enable single user mode: If you want visitors to be able to register on your Mastodon instance, then don’t enable single user mode.
  • Are you using Docker to run Mastodon: No.
  • PostgreSQL host: 127.0.0.1
  • PostgreSQL port: 5432
  • PostgreSQL database: mastodon
  • PostgreSQL user: mastodon
  • PostgreSQL user password: enter the password for the mastodon user which is created in step 1.
  • Redis host: 127.0.0.1
  • Redis port: 6379
  • Redis password: Just press Enter, because there’s no password for Redis.
  • Do you want to store uploaded files on the cloud? If you want to store user-uploaded files in S3 object storage, then you can choose Yes. I just want to store files on my own server, so I choose No.
  • Do you want to send emails from localhost? If this is your mail server, or you have set up an SMTP relay, then you can choose Yes. If you choose No, then you need to enter your SMTP server login credentials.
  • E-mail address to send e-mails “from”: You can press Enter to use the default sender email address.
  • Send a test e-mail with this configuration right now? Choose Yes to send a test email.
  • Send test e-mail to: Enter the test email address.
  • Save configuration? Choose Yes.

mastodon Create a configuration file

Next, Choose Yes to set up the database.

Now that configuration is saved, the database schema must be loaded.
If the database already exists, this will erase its contents.
Prepare the database now? y

Finally, choose Yes to compile CSS/JS assets.

The final step is compiling CSS/JS assets.
This may take a while and consume a lot of RAM.
Compile the assets now? (Y/n) y

ubuntu mastodon setup wizard

Hint: If Mastodon fails to compile, you should upgrade the server to 2 CPU cores and 3G RAM. If you use Kamatera VPS, it allows you to temporarily upgrade the server CPU and RAM for free without a reboot (Hot Add). Then run the following command again to compile Mastodon CSS/JS assets. Make sure you change back to the original server specs, so Kamatera won’t charge extra dollars for CPU/RAM hot add.

sudo -u mastodon RAILS_ENV=production bundle exec rake mastodon:setup

Once that’s done, you can create an admin user.

Do you want to create an admin user straight away? Yes
Username: super_admin
E-mail: [email protected]
You can login with the password: 0b8c9359a98059aWg0yhPyVP3eeOn6715eeb

Step 4: Start Mastodon

Mastodon provides convenient systemd service templates. We can copy them to the /etc/sysetmd/system/ directory.

sudo cp /var/www/mastodon/dist/mastodon*.service /etc/systemd/system/

Then we need to make some changes to the .service files. Change the working directory from /home/mastodon/live/ to /var/www/mastodon/.

sudo sed -i 's/home\/mastodon\/live/var\/www\/mastodon/g' /etc/systemd/system/mastodon-*.service

Change /home/mastodon/.rbenv/shims/bundle to /usr/local/bin/bundle.

sudo sed -i 's/home\/mastodon\/.rbenv\/shims/usr\/local\/bin/g' /etc/systemd/system/mastodon-*.service

Reload systemd for the changes to take effect.

sudo systemctl daemon-reload

Start the 3 systemd services.

sudo systemctl enable --now mastodon-web mastodon-sidekiq mastodon-streaming

Check status. Make sure they are all in active (running) state.

sudo systemctl status mastodon-web mastodon-sidekiq mastodon-streaming

Wait a few seconds, then run the following command to check if Mastodon is listing on port 3000.

sudo ss -lnpt | grep 3000

If Mastodon is running properly, it should output:

LISTEN 0   1024   127.0.0.1:3000    0.0.0.0:*    users:(("ruby2.7",pid=43543,fd=5),("ruby2.7",pid=43535,fd=5),("ruby2.7",pid=43520,fd=5))

If port 3000 thousand is already taken by another process, you need to edit the /etc/systemd/system/mastodon-web.service file.

sudo nano /etc/systemd/system/mastodon-web.service

Find the following line.

Environment="PORT=3000"

Change the port number like 3001, so Mastodon will be listening on port 3001. Reload systemd and restart Mastodon.

sudo systemctl daemon-reload

sudo systemctl restart mastodon-web

Step 5: Configure Nginx Reverse Proxy

Install Nginx web server from the default Ubuntu 22.04/20.04 software repository.

sudo apt install nginx

Copy the Nginx template configuration file.

sudo cp /var/www/mastodon/dist/nginx.conf /etc/nginx/conf.d/mastodon.conf

Edit the new file.

sudo nano /etc/nginx/conf.d/mastodon.conf

Find the following line in both the port 80 server block and port 443 server block.

server_name example.com;

Change the server name. Don’t forget to add DNS A record for the domain name.

server_name social.example.com;

Find the following line in both the port 80 server block and port 443 server block.

root /home/mastodon/live/public;

Change it to:

root /var/www/mastodon/public;

Find the following two lines.

 # ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
# ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;

Change them to the following, so Nginx will tempoarily use a self-signed TLS certificate. We will obtain a valid Let’s Encrypt certificate later.

ssl_certificate /etc/ssl/certs/ssl-cert-snakeoil.pem;
ssl_certificate_key /etc/ssl/private/ssl-cert-snakeoil.key;

Save and close the file. Create the cache directory.

sudo mkdir -p /var/nginx/cache/

Then test Nginx configuration.

sudo nginx -t

If the test is successful, reload Nginx for the changes to take effect.

sudo systemctl reload nginx

Now you should be able to see the Mastodon forum at http://social.example.com.

Step 7: Enable HTTPS

To encrypt HTTP traffic, we can enable HTTPS by installing a free TLS certificate issued from Let’s Encrypt. Run the following command to install Let’s Encrypt client (certbot) on Ubuntu 22.04/20.04 server.

sudo apt install certbot python3-certbot-nginx

Next, run the following command to obtain and install TLS certificate.

sudo certbot --nginx --agree-tos --redirect --hsts --staple-ocsp --email [email protected] -d social.example.com

Where

  • --nginx: Use the nginx plugin.
  • --agree-tos: Agree to terms of service.
  • --redirect: Force HTTPS by 301 redirect.
  • --hsts: Add the Strict-Transport-Security header to every HTTP response. Forcing browser to always use TLS for the domain. Defends against SSL/TLS Stripping.
  • --staple-ocsp: Enables OCSP Stapling. A valid OCSP response is stapled to the certificate that the server offers during TLS.
  • --email: an email address is required to receive important email notification for your TLS certificates.

The certificate should now be obtained and automatically installed.

mastodon letsencrypt https

And you can access Mastodon forum via HTTPS (https://social.example.com).

mastodon login page

And you can login using the admin account created in step 3. After login, you should change the password.

Hint: My Mastodon account: https://social.linuxbabe.com/@super_admin

Can’t Send Emails?

If Mastodon fails to send emails, you can find out what went wrong by going to the https://social.example.com/sidekiq/retries URL, assuming you are logged in as the admin user.

It will show you the failed emails and why email sending failed.

mastodon SMTP error

As you can see from the above screenshot, localhost:25 refused connection from my Mastodon installation. It turned out that I moved Mastodon to a bigger server but forgot to set up SMTP relay. Once SMTP relay is configured, email sending is working again.

If there are still problems in SMTP, please check the Postfix mail log file.

sudo tail /var/log/mail.log

or

sudo vim /var/log/mail.log

How to Back Up and Restore Mastodon Database

Dump the database into a tar archive.

sudo -u postgres -i pg_dump -F t mastodon > mastodon_pgsql.tar

Restore the database.

sudo -u postgres -i pg_restore --clean --dbname=mastodon /path/to/the/mastodon_pgsql.tar

If you see the following error during restoration. Ignore it. pg_restore will automatically create the missing database tables (relations).

pg_restore: error: could not execute query: ERROR:  relation "public.custom_filters" does not exist

To back up the /var/www/mastodon/ folder, I recommend using Duplicati.

Troubleshooting Mastodon Runtime Error

If the Mastodon web page isn’t working, you should check the sysetmd journals.

sudo journalctl -eu mastodon-web

sudo journalctl -eu mastodon-sidekiq

sudo journalctl -eu mastodon-streaming

How to Upgrade Mastodon

First, back up the database as mentioned above.

Then go to the Mastodon web root directory.

cd /var/www/mastodon/

Fetch new release tags.

sudo -u mastodon git fetch --tags

Sample output:

 * [new tag]             v3.5.4                                                          -> v3.5.4
 * [new tag]             v3.5.5                                                          -> v3.5.5
 * [new tag]             v4.0.0                                                          -> v4.0.0
 * [new tag]             v4.0.0rc1                                                       -> v4.0.0rc1
 * [new tag]             v4.0.0rc2                                                       -> v4.0.0rc2
 * [new tag]             v4.0.0rc3                                                       -> v4.0.0rc3
 * [new tag]             v4.0.0rc4                                                       -> v4.0.0rc4
 * [new tag]             v4.0.1                                                          -> v4.0.1
 * [new tag]             v4.0.2                                                          -> v4.0.2

Upgrade to v4.0.2

sudo -u mastodon git checkout v4.0.2

Migrate the database.

sudo -u mastodon RAILS_ENV=production bundle exec rake db:migrate

Compile the assets.

sudo -u mastodon bundle install -j$(getconf _NPROCESSORS_ONLN)

sudo -u mastodon RAILS_ENV=production bundle exec rails assets:precompile

Migrate the database again.

sudo -u mastodon RAILS_ENV=production bundle exec rake db:migrate

Once that’s done. Restart Mastodon.

sudo systemctl restart mastodon-web mastodon-sidekiq mastodon-streaming

Conclusion

I hope this article helped you install Mastodon forum software on Ubuntu 22.04/20.04. As always, if you found this post useful, then subscribe to our free newsletter to get more tips and tricks. Take care 🙂

Rate this tutorial
[Total: 29 Average: 4.9]

85 Responses to “How to Install Mastodon on Ubuntu 22.04/20.04 Server

  • Unfortunately I always receive an error while trying to install bundler

    ERROR: Could not find a valid gem ‘bundler’ (>= 0), here is why:
    Unable to download data from https://rubygems.org/ – timed out (https://rubygems.org/specs.4.8.gz)

  • Propper
    2 years ago

    Please, where to find the .env file?

    • Xiao Guoan (Admin)
      2 years ago

      Hi Propper,

      Some commands require you to be in the /var/www/mastodon/ directory, which stores the .env files.

      cd /var/www/mastodon
      • Propper
        2 years ago

        @Xiao
        Thank you for your quick reply. My fingers were faster than my thoughts… sorry about that.
        Could not find (see) the [.env] file because of the [.]

        Very good post, Mastodon runs right away.
        Thx

  • I cannot figure out how to fix

    An error occurred while installing openssl (2.2.0), and Bundler cannot continue.
    In Gemfile:
      webauthn was resolved to 3.0.0.alpha1, which depends on
        openssl
    

    I presume i need a older version of openssl, but i dont know how to install it.

    • Xiao Guoan (Admin)
      2 years ago

      Are you using Ubuntu 22.04?

    • Xiao Guoan (Admin)
      2 years ago

      Please use Ubuntu 20.04

      • Oh wow, my bad. Thanks for help. <3

        • I am using 22.04, and am not having the problem Xiao mentions, so I’m thinking that the main post must have been updated in the meantime so it’s not an issue.

        • I am using 22.04, and am not having the problem pia mentions, so I’m thinking that the main post must have been updated in the meantime so it’s not an issue.

  • error @mastodon/mastodon@: The engine "node" is incompatible with this module. Expected version ">=12". Got "10.19.0"
    error Found incompatible module.
    

    I don’t seem to be able to convince it there is actually a newer node module already, how can I resolve this – I’m not quite sure I understand why it thinks there is 10.19.0 when a node -v says v19.0.1

    • Xiao Guoan (Admin)
      1 year ago

      Mastodon isn’t compatible with NodeJS v18 and v19. You can use v16.

  • Works like a charm thank you

  • Unfortunately not working.

    root@localhost:/var/www/mastodon# gem env
    RubyGems Environment:
      - RUBYGEMS VERSION: 3.1.2
      - RUBY VERSION: 2.7.0 (2019-12-25 patchlevel 0) [x86_64-linux-gnu]
      - INSTALLATION DIRECTORY: /var/lib/gems/2.7.0
      - USER INSTALLATION DIRECTORY: /root/.gem/ruby/2.7.0
      - RUBY EXECUTABLE: /usr/bin/ruby2.7
      - GIT EXECUTABLE: /usr/bin/git
      - EXECUTABLE DIRECTORY: /usr/local/bin
      - SPEC CACHE DIRECTORY: /root/.gem/specs
      - SYSTEM CONFIGURATION DIRECTORY: /etc
      - RUBYGEMS PLATFORMS:
        - ruby
        - x86_64-linux
      - GEM PATHS:
         - /var/lib/gems/2.7.0
         - /root/.gem/ruby/2.7.0
         - /usr/lib/ruby/gems/2.7.0
         - /usr/share/rubygems-integration/2.7.0
         - /usr/share/rubygems-integration/all
         - /usr/lib/x86_64-linux-gnu/rubygems-integration/2.7.0
      - GEM CONFIGURATION:
         - :update_sources => true
         - :verbose => true
         - :backtrace => false
         - :bulk_threshold => 1000
      - REMOTE SOURCES:
         - https://rubygems.org/
      - SHELL PATH:
         - /usr/local/sbin
         - /usr/local/bin
         - /usr/sbin
         - /usr/bin
         - /sbin
         - /bin
         - /usr/games
         - /usr/local/games
         - /snap/bin
    
    sudo journalctl -eu mastodon-web
    Nov 10 20:16:59 localhost systemd[19890]: mastodon-web.service: Failed to execute command: No such file or directory
    Nov 10 20:16:59 localhost systemd[19890]: mastodon-web.service: Failed at step EXEC spawning /home/mastodon/.rbenv/shims/bundle: No such file or directo>
    Nov 10 20:16:59 localhost systemd[1]: mastodon-web.service: Main process exited, code=exited, status=203/EXEC
    Nov 10 20:16:59 localhost systemd[1]: mastodon-web.service: Failed with result 'exit-code'.
    Nov 10 20:16:59 localhost systemd[1]: mastodon-web.service: Scheduled restart job, restart counter is at 3.
    Nov 10 20:16:59 localhost systemd[1]: Stopped mastodon-web.
    
    sudo journalctl -eu mastodon-sidekiq
    Nov 10 20:16:59 localhost systemd[19889]: mastodon-sidekiq.service: Failed to execute command: No such file or directory
    Nov 10 20:16:59 localhost systemd[19889]: mastodon-sidekiq.service: Failed at step EXEC spawning /home/mastodon/.rbenv/shims/bundle: No such file or dir>
    Nov 10 20:16:59 localhost systemd[1]: mastodon-sidekiq.service: Main process exited, code=exited, status=203/EXEC
    Nov 10 20:16:59 localhost systemd[1]: mastodon-sidekiq.service: Failed with result 'exit-code'.
    Nov 10 20:16:59 localhost systemd[1]: mastodon-sidekiq.service: Scheduled restart job, restart counter is at 3.
    Nov 10 20:16:59 localhost systemd[1]: Stopped mastodon-sidekiq.
    
    • Xiao Guoan (Admin)
      1 year ago

      The systemd status output indicates that it was trying to find the /home/mastodon/.rbenv/shims/bundle binary.

      Please follow step 4 to change the working directory from /home/mastodon/live/ to /var/www/mastodon/.

      And change /home/mastodon/.rbenv/shims/bundle to /usr/local/bin/bundle.

      You can copy and paste my commands, or open the systemd service files and change them manually. Be careful of typo mistakes.

  • I installed locally. I have NPM setup, but I cannot get the interface to load after running through this entire tutorial twice. I set Lets Encrypt through NPM, but cannot even access locally (direct IP). Any ideas?

  • Hiya. They just fixed compatibility with Openssl 3.0
    https://github.com/mastodon/mastodon/releases/tag/v4.0.0

    • Xiao Guoan (Admin)
      1 year ago

      Thanks for your notification. I just updated this article.

  • Xiao Guoan (Admin)
    1 year ago

    For Ubuntu 22.10 users:

    Ubuntu 22.10 ships with NodeJS v18, which isn’t compatible with Mastodon now. After adding the nodejs repository as mentioned in this article, you should run the following command to list available nodejs packages.

    apt-cache policy nodejs

    Sample output:

    nodejs:
      Installed: 16.18.1-deb-1nodesource1
      Candidate: 18.7.0+dfsg-5ubuntu1
      Version table:
         18.7.0+dfsg-5ubuntu1 500
            500 http://us.archive.ubuntu.com/ubuntu kinetic/universe amd64 Packages
         16.18.1-deb-1nodesource1 500
            500 https://deb.nodesource.com/node_16.x kinetic/main amd64 Packages
            100 /var/lib/dpkg/status
    

    Then download nodejs from the nodesource repository.

    sudo apt download nodejs=16.18.1-deb-1nodesource1

    Install this package.

    sudo apt install ./nodejs_16.18.1-deb-1nodesource1_amd64.deb
  • Thanks for this excellent guide! I used it a few weeks ago to install 3.5.3 on 20.04. I was trying to do the upgrade listed here, it appears to go smoothly, but when its done, I keep getting a ‘something went wrong’ splash page. Is there an intermediate step I should do between 3.5.3 and 4.0.2 (like when it goes to 4.0.0?)

  • Whoopee
    1 year ago

    I got so close! I’m getting ERR_TOO_MANY_REDIRECTS and the site won’t load. Are there logs I can share that will help get it fixed?

  • Thanks, Xiao, for the best instructions I have seen in a very long time. I had tried several others before finding LinuxBabe, and they all had significant gaps. Xiao, yours is the Gold Standard, IMHO. I was happy to see you move the site to /var/www/mastodon/public out of the /home directory.

    The one issue I have is a problem running tootctl. It says Could not find rake.

    ubuntu@ip-x-x-x-x:/var/www/mastodon/bin$ ./tootctl help
    Could not find rake-13.0.6 in any of the sources
    Run `bundle install` to install missing gems.
    

    I tried running “bundle install,” but that did not resolve the issue. I have the environment variable set in .bashrc to production.

    Thanks for any help, and thank again for your hard work.
    Jay

    • Xiao Guoan (Admin)
      1 year ago

      Hi Jay,

      I use the following method to run tootctl.

      cd /var/www/mastodon
      
      sudo -u mastodon RAILS_ENV=production bin/tootctl help
      
      • Hi Xiao and thanks for your suggestion. I tried it and get the same “Could not find rake…”

        ubuntu@ip-172-26-1-32:/var/www/mastodon$ sudo -u mastodon RAILS_ENV=production bin/tootctl help
        Could not find rake-13.0.6 in any of the sources
        Run `bundle install` to install missing gems.

        A search for rake shows:

        ubuntu@ip-172-26-1-32:/var/www/mastodon$ find . -name rake
        ./vendor/bundle/ruby/2.7.0/gems/railties-6.1.7/lib/rails/commands/rake
        ./vendor/bundle/ruby/2.7.0/gems/scenic-1.6.0/spec/dummy/bin/rake
        ./vendor/bundle/ruby/2.7.0/gems/scenic-1.6.0/bin/rake
        ./vendor/bundle/ruby/2.7.0/gems/chunky_png-1.4.0/bin/rake
        ./vendor/bundle/ruby/2.7.0/gems/sprockets-3.7.2/lib/rake
        ./vendor/bundle/ruby/2.7.0/gems/doorkeeper-5.6.0/lib/doorkeeper/rake
        ./vendor/bundle/ruby/2.7.0/gems/rake-13.0.6/lib/rake
        ./vendor/bundle/ruby/2.7.0/gems/rake-13.0.6/exe/rake
        ./vendor/bundle/ruby/2.7.0/bundler/gems/webpush-f14a4d52e201/bin/rake
        ./vendor/bundle/ruby/2.7.0/bin/rake
        ./bin/rake

        Thanks again for your help.

    • Xiao Guoan (Admin)
      1 year ago

      Maybe you need to run the following commands again?

      cd /var/www/mastodon/
      
      sudo -u mastodon bundle config deployment 'true'
      
      sudo -u mastodon bundle config without 'development test'
      
      sudo -u mastodon bundle install -j$(getconf _NPROCESSORS_ONLN)
      
      • Hello again. I can’t thank you enough for your help. I reran those commands, but no luck.

        ubuntu@ip-172-26-1-32:~$ cd /var/www/mastodon/
        ubuntu@ip-172-26-1-32:/var/www/mastodon$ RAILS_ENV=production ./bin/tootctl --version
        Could not find rake-13.0.6 in any of the sources
        Run `bundle install` to install missing gems.
        
        ubuntu@ip-172-26-1-32:/var/www/mastodon$ sudo -u mastodon bundle config deployment 'true'
        
        ubuntu@ip-172-26-1-32:/var/www/mastodon$ sudo -u mastodon bundle config without 'development test'
        You are replacing the current local value of without, which is currently "development:test"
        
        ubuntu@ip-172-26-1-32:/var/www/mastodon$ sudo -u mastodon bundle install -j$(getconf _NPROCESSORS_ONLN)
        Fetching gem metadata from https://rubygems.org/.........
        Using rake 13.0.6
        .
        .
        .
        Using rails 6.1.7
        Using rails-settings-cached 0.6.6
        Bundle complete! 124 Gemfile dependencies, 226 gems now installed.
        Gems in the groups 'development' and 'test' were not installed.
        Bundled gems are installed into `./vendor/bundle`
         
        ubuntu@ip-172-26-1-32:/var/www/mastodon$ sudo -u mastodon RAILS_ENV=production bin/tootctl help
        Could not find rake-13.0.6 in any of the sources
        Run `bundle install` to install missing gems.

        The response said, “Gems in the groups ‘development’ and ‘test’ were not installed.” Is that normal?

        Everything else with the installation appears to be working fine. It’s a shame they had to make the tootctl so convoluted. I have not found anything in the log files that shed any light.

        ubuntu@ip-172-26-1-32:/var/www/mastodon$ cd /
        ubuntu@ip-172-26-1-32:/$ sudo find . -name rake-*
        ./var/www/mastodon/vendor/bundle/ruby/2.7.0/gems/rake-13.0.6
        ./var/www/mastodon/vendor/bundle/ruby/2.7.0/cache/rake-13.0.6.gem
        ./var/www/mastodon/vendor/bundle/ruby/2.7.0/specifications/rake-13.0.6.gemspec
        ./var/www/mastodon/.bundle/cache/compact_index/rubygems.org.443.29b0360b937aa4d161703e/info/rake-compiler
        ./usr/share/rubygems-integration/all/gems/rake-13.0.1
        ./usr/share/rubygems-integration/all/specifications/rake-13.0.1.gemspec
        ./home/ubuntu/.bundle/cache/compact_index/rubygems.org.443.29b0360b937aa4d161703e/info/rake-compiler
        ./home/mastodon/.bundle/cache/compact_index/rubygems.org.443.29b0360b937aa4d161703e/info/rake-compiler
        ubuntu@ip-172-26-1-32:/$ 
        ubuntu@ip-172-26-1-32:/$ ruby -v
        ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-linux-gnu]

        Thanks again for your help,
        Jay

        • I’m happy to report that my “missing tootctl – rake-13.0.6” issue has been resolved. I initially tried to install it using ubuntu 22.10 x64 which failed to compile. I’m sure it’s a well-documented issue, but I missed it. So I found that 20.04 (LTS) x64 would compile, and Mastodon ran with no apparent issues except I could not run the tootctl script, which reported: “could not find rake-13.0.6”. Once I realized I should have been using 22.04 (LTS) x64, everything worked as expected, along with the tootctl script. I can’t thank Xiao for his help and patience.

    • Xiao Guoan (Admin)
      1 year ago

      Install rake from the Ubuntu repository.

      sudo apt install rake

      Check rake version.

      rake -V

      Sample output:

      rake, version 13.0.6
      • Stephen
        1 year ago

        Hmm, I have a somewhat similar problem. My installed rake however shows as
        rake, version 13.0.1

        How do I force it to get updated to 13.0.6?

        Thanks

    • Xiao Guoan (Admin)
      1 year ago

      Or you should set the path before installing the gems.

      cd /var/www/mastodon/
      
      sudo -u mastodon RAILS_ENV=production /usr/local/bin/bundle config set path '/var/www/mastodon/vendor/bundle/'
      
      sudo -u mastodon RAILS_ENV=production /usr/local/bin/bundle install
      
  • Hi there! Yesterday I used the prior version of this page to get mastodon 3.5.3 running successfully. It was great! Today I found the newer version of this page and used your instructions to upgrade to mastodon 4.0.2. There were no errors in setting the tag and rebuilding… but I’m now getting runtime errors from the mastodon web service, which is throwing a 500 to the user’s GET request:

    ActionView::Template::Error (undefined local variable or method `role_id' for #
    Did you mean?  role):
    
     7:   %meta{ name: 'applicationServerKey', content: Rails.configuration.x.vapid_public_key }
     8:
    9:   = render_initial_state
    10:   = javascript_pack_tag 'application', crossorigin: 'anonymous'
     11:
    12: .notranslate.app-holder#mastodon{ data: { props: Oj.dump(default_props) } }
    
  • Replying to myself: all fixed! Turns out the db needed to be upgraded to get from 3.5 to 4.0, which you can see at the bottom of the 4.0 release notes here (https://github.com/mastodon/mastodon/releases/tag/v4.0.0). You need to update your ‘how to upgrade’ section to include the two db:migrate commands — one before the assets:precompile, and one again afterwards. Nevertheless, I sent you a paypal tip! Thanks for the great guide!

    • Xiao Guoan (Admin)
      1 year ago

      Thanks for your tip 🙂 (Pun intended)

  • Great guide, all went smoothly even email worked, but upon loading the site I just get a white blank page with the mastodon logo top left in any broswer, tried rebooting the server, can’t see any errors, any idea?

    • Fixed, i left ‘live’ in the lines to change: root /var/www/mastodon/public

      All working. Brilliant guide.

  • Hello. Great guide. I am excited to give it a try. Do you have any instructions to install elasticsearch as well?

  • Zaraki
    1 year ago

    Thank you for the wonderful instructions. Everything worked just fine. I only have one question. Instead of saving the files to the server, I want to use StorJ as S3. Since this can’t be done directly through the “install wizard”, I need to edit it directly in the cfg file. The problem is that the instructions says “For convenience, it can read them from a flat file called .env.production in the Mastodon directory (called a “dotenv” file), but they can always be overridden by a specific process.” , but I can’t find that file anywhere.

    Do you have any advice on where I can find it after installation? It’s strange, because when I followed the instructions elsewhere I had it there, but everything else didn’t work. :))

  • bakamenon
    1 year ago

    hi Xiao! Great tutorial… Would it be possible for your to explain a bit on how to go about attaching a block storage for added storage? Thank you!

  • Andrew
    1 year ago

    I have followed these instructions twice and my website only shows the Mastodon logos nothing else. I have attached a screenshot

    • Xiao Guoan (Admin)
      1 year ago

      Check your Nginx logs to find out what went wrong. (/var/log/nginx/error.log and /var/log/nginx/access.log)

    • I had that by mssing the word live removal here:
      Find the following line in both the port 80 server block and port 443 server block.

      root /home/mastodon/live/public;

      Change it to:

      root /var/www/mastodon/public;

  • Thank you for this guide, and for keeping it updated.
    I installed 2 ubuntu servers from your instructions and ran into a couple issues with missing gem files as other folks in the comments here and figured them out by Googling.

    One issue I ran into was the Federated timeline in both servers stopped working after 3 days and it turns out that the /etc/systemd/system/mastodon-sidekiq.service file needs to be updated to specify each of the queues being used, so in this line of the file:

    ExecStart=/usr/local/bin/bundle exec sidekiq -c 25

    I had to append -q ingress -q scheduler -q default -q push -q mailers -q pull
    and then restart the mastodon-sidekiq service.

    Again, many thanks for this quide.

  • Juglugs
    1 year ago

    Absolutely brilliant instruction – thank you!
    (Follow me at @[email protected])

    In the PGHero app, how do I enable the Query Stats? It says: “Query stats are available but not enabled.”

    When I press the button, I get “The database user does not have permission to enable query stats”

    I’ve tried looking this up myself, and I’ve added the following to /etc/postgresql/15/main/postgresql.conf:

    shared_preload_libraries = 'pg_stat_statements'
    pg_stat_statements.max = 10000
    pg_stat_statements.track = all
    

    And I’ve logged into psql using

    sudo -u postgres -i psql
    

    and entered:

    CREATE extension pg_stat_statements;
    

    Then I restart everything (by the command line and actually restarting my PC) but it still fails to work. I get the same error on the PGHero screen.

  • Hi – I created an instance when folks started leaving Twitter. I have about 100 users, and I’m looking to move the instance to a new server. Would I just conduct a fresh install on the new server following your instructions – then follow your instructions to backup and restore the database front he old to the new server, then redirect my domain to the new IP? Anything else I should consider (such as in the mastodon root directory)? The instance has about 100 users.

    Greatly appreciate this – and all your other tutorials. I’m running LAMP, NextCloud, iRedMail, and more as a result of your tutorials (donation is long overdue)!

    • Xiao Guoan (Admin)
      1 year ago

      On the new server:

      Follow step 1 to create an empty database and a database user. (The database user password can be found in the /var/www/mastodon/.env.production file.
      Follow Step 2 to install Ruby
      Follow Step 3 to create the mastodon user, and install nodejs, yarn, and bundler. Don’t start the setup wizard.

      Then back up the database on the old server and restore it on the new server. If you see the following error during restoration. Ignore it. pg_restore will automatically create the missing database tables (relations).

      pg_restore: error: could not execute query: ERROR:  relation "public.custom_filters" does not exist

      Also, copy the /var/www/mastodon/ directory to the new server, and install dependency packages.

      cd /var/www/mastodon
      
      sudo -u mastodon bundle config deployment 'true'
      
      sudo -u mastodon bundle config without 'development test'
      
      sudo -u mastodon bundle install -j$(getconf _NPROCESSORS_ONLN)
      

      Next, Copy the systemd service files, let’s encrypt folder, Nginx config file to the new server.

      Start Mastodon:

      sudo systemctl enable --now mastodon-web mastodon-sidekiq mastodon-streaming

      Check status. Make sure they are all in active (running) state.

      sudo systemctl status mastodon-web mastodon-sidekiq mastodon-streaming

      Restart Nginx.

      sudo systemctl restart nginx

      Change the DNS A record.

  • please

    root@mastodon:/var/www/mastodon# sudo systemctl reload nginx
    nginx.service is not active, cannot reload.

    • nginx.service – A high performance web server and a reverse proxy server
      Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
      Active: failed (Result: exit-code) since Mon 2022-12-05 14:11:52 UTC; 19s ago
      Docs: man:nginx(8)
      Process: 21084 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
      Process: 21085 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=1/FAILURE)

      Dec 05 14:11:50 mastodon.LML nginx[21085]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
      Dec 05 14:11:50 mastodon.LML nginx[21085]: nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
      Dec 05 14:11:51 mastodon.LML nginx[21085]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
      Dec 05 14:11:51 mastodon.LML nginx[21085]: nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
      Dec 05 14:11:51 mastodon.LML nginx[21085]: nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
      Dec 05 14:11:51 mastodon.LML nginx[21085]: nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
      Dec 05 14:11:52 mastodon.LML nginx[21085]: nginx: [emerg] still could not bind()
      Dec 05 14:11:52 mastodon.LML systemd[1]: nginx.service: Control process exited, code=exited, status=1/FAILURE
      Dec 05 14:11:52 mastodon.LML systemd[1]: nginx.service: Failed with result ‘exit-code’.
      Dec 05 14:11:52 mastodon.LML systemd[1]: Failed to start A high performance web server and a reverse proxy server.

    • Xiao Guoan (Admin)
      1 year ago

      Maybe you already have another web server like Apache running? Check which process is using TCP port 80.

      sudo ss -lnpt | grep :80
  • Stephen R.
    1 year ago

    Hi – First of all, thank you very much for this guide! I installed Mastodon on a Ubuntu 22.04 VPS and I need to make modifications to the Mastodon SMTP configuration because I am not seeing any mail going out to my other Ubuntu 22.04 iRedMail VPS. What is the best way to make SMTP only configuration changes to my Mastodon instance without modifying any other configuration options? Thank you in advance! =)

    • Xiao Guoan (Admin)
      1 year ago

      You can make SMTP-only changes in the /var/www/mastodon/.env.production file.

      After the change, restart Mastodon.

      sudo systemctl restart mastodon-web mastodon-sidekiq mastodon-streaming
  • This guide is the best available and workd for me.

    I would love a guide to instal Pixelfed on the same vps server as a sub domain 🙂 I don’t have the confidence or Ubuntu skills to take that on without a guide, and don’t want to cause my mastodon install any issues.

  • Stephen
    1 year ago

    Great guide, the only difference that I have is that I build my env on Linode.com instead of your provider.

    I am also getting ERR_TOO_MANY_REDIRECTS, and it wont load. I am not using Cloudflare, but I did setup firewall with IP_TABLES as per Mastodon guide.

    Any ideas?

    • Stephen
      1 year ago

      Ok, I rebuilt using your provider and all is good. Thank you, great guide.

      Now, any docs on next steps?

      I have searched. A lot of admin tasks are not documented, or I am not finding them. Installing standard, emojis, joining the Federation, adding the blocks servers, implementing MFA, etc.

      Thank you!

  • Cindy Lawlor
    1 year ago

    This was excellent! I had a little different setup as I already have NGINX running in front of a couple of other websites I host on home server. But, a little googling and tinkering got me across the finish line. Thanks for the great work!!! Followed you on Mastodon 🙂

  • Hai Ma
    1 year ago

    Hi i have successfully configure the mastodon, but how can i save content changes to it ?

  • Thank you very much for a clear concise method and instructions on how to set up Mastodon! After many hours or fighting with on my home server (I run several WordPress instances on Apache2), I had to give up and go with a VPS. Went with VPS Servers and they seems to have a good rate. I had the instance up and running in less than 3 hours ( had a little problem with the mail server and went with the relay host you referenced).

    Thank you!

  • Thank you for this well documented guide.
    I was finally able to get my new instance built on Azure with minimal trouble using this guide.

  • What is that reason behind the change on “default” install from /home/mastodon to /var/www? If left on /home/mastodon, there is no need to modify the services files, nor the nginx, etc.

  • Hi there!

    Working through the install now – apologies as I have zero experience with Ruby.

    I’m at this point:

    > /var/www/mastodon$ sudo -u mastodon bundle install -j$(getconf _NPROCESSORS_ONLN)
    

    I’m getting this error:

    Fetching gem metadata from https://rubygems.org/.........
    Your bundle is locked to webpush (0.3.8) from https://github.com/ClearlyClaire/webpush.git (at f14a4d5@f14a4d5), but that version can no longer be found in that source. That means the author
    of webpush (0.3.8) has removed it. You'll need to update your bundle to a version other than webpush (0.3.8) that hasn't been removed in order to install.
    

    Any thoughts?

  • Yavuz Selim
    1 year ago

    Thank you very much for this tutorial. Worked flawlessly.

    There is one small issue, there is missing slash here:
    sudo nano etc/systemd/system/mastodon-web.service

    There should be a slash in front of the path, so “/etc/…”.

  • David Collantes
    1 year ago

    Xiao Guoan,

    A little bit out of the scope of this guide, but I am hoping you can help me. I managed to delete the .env.production while trying to implement a backup solution. I have database information, but not the secrets. What is the best way to re-create that file, without losing data/federation?

  • George
    1 year ago

    This is most likely buried in a ton of comments. But I wanted to say thank you for this guide I tried many different options and this was the only guide that got me up and running. Thank you.

  • blaine
    1 year ago

    Hi there.
    I am trying to install the Gab social fork of this but there are no instructions provided except for the vagrant and virtual box versions.

    Was wondering if you could help me install the gab version. I am glad to pay for it.

    Here is the code

    https://github.com/mordechaim/gab-social

    • Realize Gab forked Mastodon sometime around 2018, or 2019, and has been changing it ever since. That was probably version 3.X back then.

      You may want to look at a guide from back then, or ask on their GitHub issues section.

  • I seem to have a firewall issue.

    “ufw status” shows:

    Status: active

    To Action From
    — —— —-
    22/tcp ALLOW Anywhere
    443/tcp ALLOW Anywhere
    80/tcp ALLOW Anywhere
    22/tcp (v6) ALLOW Anywhere (v6)
    443/tcp (v6) ALLOW Anywhere (v6)
    80/tcp (v6) ALLOW Anywhere (v6)

    access.log for nginx shows nothing for outside attempts to access, but if I do wget wget http://localhost or wget https://localhost –no-check-certificate then I get a hit in the logs.

    Any clues?

  • Santosh Pandit
    1 year ago

    Good work! I had to add –no-check-certificate to the wget command (for postgres) to make it work.

  • Steven
    1 year ago

    Hi, running out of disk space, so I read that I can use tootctl to clean disk space.

    As I installed with you process what I try is:
    sudo -u mastodon RAILS_ENV=production /var/www/mastodon/bin/tootctl media remove

    But getting the following error:
    Could not find rake-13.0.6 in any of the sources
    Run `bundle install` to install missing gems.

    Is something wrong with my install? I have now 50+ users. Thanks!

  •  *2358 open() "/usr/share/nginx/html/.git/config" failed (2: No such file or directory), client: 185.224.128.219, server: mail.allgays.xyz, request: "GET /.git/config HTTP/1.1", host: "208.113.129.51"
    2023/01/24 04:37:00 [error] 165001#165001: *2410 open() "/usr/share/nginx/html/boaform/admin/formLogin" failed (2: No such file or directory), client: 195.154.77.190, server: mail.allgays.xyz,  request: "POST /boaform/admin/formLogin HTTP/1.1", host: "208.113.129.51:80", referrer: "http://208.113.129.51:80/admin/login.asp"
    2023/01/24 04:46:56 [error] 165001#165001: *2542 open() "/usr/share/nginx/html/ReportServer" failed (2: No such file or directory), client: 107.170.225.15, server: mail.allgays.xyz, request: "GET /ReportServer HTTP/1.1", host: "208.113.129.51"
    2023/01/24 05:47:28 [error] 165001#165001: *3282 open() "/usr/share/nginx/html/actuator/gateway/routes" failed (2: No such file or directory), client: 152.89.196.211, server: mail.allgays.xyz, request: "GET /actuator/gateway/routes HTTP/1.1", host: "208.113.129.51:80"
    2023/01/24 06:41:39 [error] 165001#165001: *3962 open() "/usr/share/nginx/html/boaform/admin/formLogin" failed (2: No such file or directory), client: 37.44.238.168, server: mail.allgays.xyz, request: "POST /boaform/admin/formLogin HTTP/1.1", host: "208.113.129.51:80", referrer: "http://208.113.129.51:80/admin/login.asp"
    2023/01/24 07:01:40 [error] 165001#165001: *4231 open() "/usr/share/nginx/html/favicon.ico" failed (2: No such file or directory), client: 164.52.25.251, server: mail.allgays.xyz, request: "GET /favicon.ico HTTP/1.1", host: "208.113.129.51"
    2023/01/24 08:06:06 [error] 165001#165001: *5041 open() "/usr/share/nginx/html/boaform/admin/formLogin" failed (2: No such file or directory), client: 205.185.118.237, server: mail.allgays.xyz, request: "POST /boaform/admin/formLogin HTTP/1.1", host: "208.113.129.51:80", referrer: "http://208.113.129.51:80/admin/login.asp"
    2023/01/24 08:36:29 [error] 165001#165001: *5389 open() "/usr/share/nginx/html/admin/config.php" failed (2: No such file or directory), client: 185.224.128.219, server: mail.allgays.xyz, request: "GET /admin/config.php HTTP/1.1", host: "208.113.129.51"
    2023/01/24 10:19:03 [error] 165001#165001: *6778 open() "/usr/share/nginx/html/.env" failed (2: No such file or directory), client: 172.174.225.199, server: mail.allgays.xyz, request: "GET /.env HTTP/1.1", host: "208.113.129.51"
    2023/01/24 10:19:03 [error] 165001#165001: *6779 open() "/usr/share/nginx/html/.env" failed (2: No such file or directory), client: 172.174.225.199, server: mail.allgays.xyz, request: "GET /.env HTTP/1.1", host: "208.113.129.51"
    2023/01/24 10:19:04 [error] 165001#165001: *6780 open() "/usr/share/nginx/html/vendor/phpunit/phpunit/src/Util/PHP/eval-stdin.php" failed (2: No such file or directory), client: 172.174.225.199, server: mail.allgays.xyz, request: "GET /vendor/phpunit/phpunit/src/Util/PHP/eval-stdin.php HTTP/1.1", host: "208.113.129.51"
    2023/01/24 12:35:38 [error] 165001#165001: *8550 open() "/usr/share/nginx/html/manager/text/list" failed (2: No such file or directory), client: 198.199.104.136, server: mail.allgays.xyz, request: "GET /manager/text/list HTTP/1.1", host: "208.113.129.51"
    2023/01/24 13:10:03 [error] 165001#165001: *9117 open() "/usr/share/nginx/html/manager/html" failed (2: No such file or directory), client: 198.199.104.26, server: mail.allgays.xyz, request: "GET /manager/html HTTP/1.1", host: "208.113.129.51"
    2023/01/24 13:53:03 [crit] 165001#165001: *9706 SSL_do_handshake() failed (SSL: error:0A00006C:SSL routines::bad key share) while SSL handshaking, client: 128.14.234.191, server: 0.0.0.0:443
    2023/01/24 15:46:00 [error] 165001#165001: *11239 open() "/usr/share/nginx/html/sdk" failed (2: No such file or directory), client: 47.252.13.90, server: mail.allgays.xyz, request: "POST /sdk HTTP/1.1", host: "208.113.129.51"
    2023/01/24 15:46:00 [error] 165001#165001: *11240 open() "/usr/share/nginx/html/1674575160" failed (2: No such file or directory), client: 47.252.13.90, server: mail.allgays.xyz, request: "GET /1674575160 HTTP/1.1", host: "208.113.129.51"
    2023/01/24 15:46:01 [error] 165001#165001: *11241 open() "/usr/share/nginx/html/evox/about" failed (2: No such file or directory), client: 47.252.13.90, server: mail.allgays.xyz, request: "GET /evox/about HTTP/1.1", host: "208.113.129.51"
    2023/01/24 15:46:01 [error] 165001#165001: *11242 open() "/usr/share/nginx/html/HNAP1" failed (2: No such file or directory), client: 47.252.13.90, server: mail.allgays.xyz, request: "GET /HNAP1 HTTP/1.1", host: "208.113.129.51"
    2023/01/24 15:46:11 [error] 165001#165001: *11251 open() "/usr/share/nginx/html/favicon.ico" failed (2: No such file or directory), client: 47.252.13.90, server: mail.allgays.xyz, request: "GET /favicon.ico HTTP/1.1", host: "208.113.129.51"
    2023/01/24 15:46:11 [error] 165001#165001: *11252 open() "/usr/share/nginx/html/robots.txt" failed (2: No such file or directory), client: 47.252.13.90, server: mail.allgays.xyz, request: "GET /robots.txt HTTP/1.1", host: "208.113.129.51"
    2023/01/24 16:08:50 [crit] 165001#165001: *11580 SSL_do_handshake() failed (SSL: error:0A00006C:SSL routines::bad key share) while SSL handshaking, client: 212.102.40.218, server: 0.0.0.0:443
    2023/01/24 17:14:47 [error] 165001#165001: *12458 "/usr/share/nginx/html/c/index.html" is not found (2: No such file or directory), client: 180.149.125.159, server: mail.allgays.xyz, request: "GET /c/ HTTP/1.1", host: "208.113.129.51"
    2023/01/24 17:49:41 [error] 165001#165001: *12877 open() "/usr/share/nginx/html/robots.txt" failed (2: No such file or directory), client: 54.36.149.24, server: mail.allgays.xyz, request: "GET /robots.txt HTTP/1.1", host: "www.allgays.xyz"
    2023/01/24 18:43:42 [error] 165001#165001: *13402 open() "/usr/share/nginx/html/favicon.ico" failed (2: No such file or directory), client: 167.94.138.45, server: mail.allgays.xyz, request: "GET /favicon.ico HTTP/1.1", host: "208.113.129.51"
    2023/01/24 18:49:43 [error] 165001#165001: *13443 open() "/usr/share/nginx/html/config/getuser" failed (2: No such file or directory), client: 185.225.74.247, server: mail.allgays.xyz, request: "GET /config/getuser?index=0 HTTP/1.1", host: "208.113.129.51:80"
    2023/01/24 18:58:01 [error] 165001#165001: *13495 open() "/usr/share/nginx/html/.env" failed (2: No such file or directory), client: 194.87.200.71, server: mail.allgays.xyz, request: "GET /.env HTTP/1.1", host: "208.113.129.51"
    2023/01/24 19:44:05 [error] 165001#165001: *13864 open() "/usr/share/nginx/html/.env" failed (2: No such file or directory), client: 109.237.97.180, server: mail.allgays.xyz, request: "GET /.env HTTP/1.1", host: "208.113.129.51"
    2023/01/24 20:09:08 [error] 165001#165001: *14088 open() "/usr/share/nginx/html/admin/config.php" failed (2: No such file or directory), client: 185.224.128.219, server: mail.allgays.xyz, request: "GET /admin/config.php HTTP/1.1", host: "208.113.129.51"
    2023/01/24 20:19:00 [error] 165001#165001: *14187 open() "/usr/share/nginx/html/boaform/admin/formLogin" failed (2: No such file or directory), client: 193.35.18.242, server: mail.allgays.xyz, request: "POST /boaform/admin/formLogin HTTP/1.1", host: "208.113.129.51:80", referrer: "http://208.113.129.51:80/admin/login.asp"
    

    I hope this is still considered part of Mastodon since it is installed with it and relies on it. If not, could it please be put in the correct place?
    I get the errors above in Nginx and my federation timeline doesn’t load. I did the above with the sidekiq service and I will see how that goes but should some program have put the above files/dir in at some point? I did reinstall nginx and that didn’t add anything. Skip the errors about the mail server, I have that half working. I also get the following error

     
    *14394 connect() failed (111: Unknown error) while connecting to upstream, client: 96.2.146.130, server: allgays.xyz, request: "GET /api/v1/streaming/? HTTP/1.1", upstream: "http://127.0.0.1:4000/api/v1/streaming/?", host: "allgays.xyz"
    

    various dir after /v1/ at least 6. Some goto port 4000 (node) and some to 3000 (Bundler)

    Any help will be nice

    • charismeki
      12 months ago

      Hi Allen, I have excately the same issue. Have you sorted it out and would be so kind to post your solution?

  • C.W. Smith
    1 year ago

    I got the the point of checking to see if the mastodon setup is available prior to let’s encrypt and all I keep getting is the nginx default home screen. I am not sure why that is happening as Ihave modified the appropriate files as mentioned in the system.

  • stoony
    1 year ago

    Hey i have apache2 can you say me we i the config for apache2 ?

  • MEXXUS
    1 year ago

    Apparently, the database restore command mentioned in this howto doesn’t work. I have successfully created a backup file, but when I do this command:

    sudo -u postgres -i pg_restore –clean –dbname=mastodon /home/martinvd/mastodon_pgsql.tar

    I get this error:

    pg_restore: error: could not open input file “/home/martinvd/mastodon_pgsql.tar”: Permission denied

    • MEXXUS
      1 year ago

      I have tried different variations on this command, but there seems to be an authentication issue somewhere. Apparently, the postgres user doesn’t seem to have the proper rights to import/ use pg_respore to this database.

  • Sararig
    1 year ago

    thanks for approve my account 🙂

    deSara

  • John Bizeray
    1 year ago

    I am installing Mastadon in a Ubuntu 22.04 LXC container on Proxmox 7.3-6.
    I get the error – PG::InvalidParameterValue: ERROR: new encoding (UTF8) is incompatible with the encoding of the template database (SQL_ASCII)
    HINT: Use the same encoding as in the template database, or use template0 as template.
    Probably the easiest solution is to use a VM.

  • John Bizeray
    1 year ago

    Hi,
    I installed Ubuntu 22.04 on a VM.
    When I go to https://mastodon.mysite.uk/ I get a message “We’re sorry, but something went wrong on our end.” along with a picture of a mastodon trashing its computer.
    If I try to refresh, I get a 403 message.

    tail -f /var/log/syslog
    Mar 24 20:07:35 mastodon bundle[1033]: [ActionDispatch::HostAuthorization::DefaultResponseApp] Blocked host: mastodon.mysite.uk

    It would be much appreciated if you can help me solve this.
    Many thanks in advance!

  • This guide is excellent, thank you – works a treat.

    I’d love a similar guide on how to update Mastodon when there are new releases if you’ve used this method as the guidance available often assumes docker etc and having a guide to help ensure upgrading can be smooth without breaking everything would be mega useful.

  • sebastien
    8 months ago

    I was almost there, i have a brotli error when starting op nginx.

    nginx: [emerg] unknown directive “brotli” in /etc/nginx/conf.d/brotli.conf:1
    nginx: configuration file /etc/nginx/nginx.conf test failed

    Any tips? Runnning on ubuntu 22 with plesk

  • Neculiti Ivan
    8 months ago

    I apologise, but, in my opinion, you are not right. Write to me in PM, we will talk.

    _ _ _ _ _ _ _ _ _ _ _ _ _ _
    Neculiti Ivan nuxt github

  • thanks for the tutorial. I messed up an upgrade and this helped. Some BTC on its way. Are you on Mastodon ?

Leave a Comment

  • Comments with links are moderated by admin before published.
  • Your email address will not be published.
  • Use <pre> ... </pre> HTML tag to quote the output from your terminal/console.
  • Please use the community (https://community.linuxbabe.com) for questions unrelated to this article.
  • I don't have time to answer every question. Making a donation would incentivize me to spend more time answering questions.

The maximum upload file size: 2 MB. You can upload: image. Links to YouTube, Facebook, Twitter and other services inserted in the comment text will be automatically embedded. Drop file here