[Guide] Increase max characters posting count limit for self-hosted Mastodon server

- Posted in Guides by

If you search for the max_characters keyword in the Mastodon Github repository, you will see that it all points to the value within the StatusLengthValidator and a variable called MAX_CHARS.

MAX_CHARACTERS_LOCAL  = 255

To modify it, first, ssh into your Mastodon server, and switch to the root shell:

sudo -s

Then, switch to the Mastodon user

sudo -u mastodon -i

or

sudo -i -u mastodon

Now, modify the validator file:

nano -w PATH/live/app/validators/status_length_validator.rb

At the very top of the file, you will see the MAX_CHARS variable, which was by default 500, you can modify it to another integer, for example 3000 to allow a maximum of 3000 characters within each post.

class StatusLengthValidator < ActiveModel::Validator
  MAX_CHARS = 3000
  URL_PLACEHOLDER_CHARS = 23
  URL_PLACEHOLDER = 'x' * 23

One can do this manually via vim/nano file manager as well:

nano -w PATH/live/app/validators/status_length_validator.rb

Instantly restore ownership back to the mastodon user:

sudo chown mastodon:mastodon PATH/live/app/validators/status_length_validator.rb

One can also alternatively run the nano file as a mastodon user instead:

sudo -u mastodon nano -w PATH/live/app/validators/status_length_validator.rb

Exit to root shell and restart the Mastodon processes, or simply reboot.

exit
systemctl restart mastodon*