Question about max username length

In Usernames on top, lifting username length restrictions, there is a lengthy discussion about lifting the max username length restriction.

The first post gives an example of the length being increased to 40, but Usernames on top, lifting username length restrictions (post 25) says that it has been officially bumped from 15 to 20.

Is it safe to make it more than 20 characters? The reason I ask is because we’ve tied our Discourse implementation to our LDAP system for SSO, and we’re using the LDAP usernames as the Discourse usernames … and some of our users have got very long names, e.g. moorthy.baskaravenkatraman-sambamoorthy.

What is the maximum length that the system has been tested with? I don’t want to break Discourse by putting in a value that is too high …


1 Like

Great idea, I’ve been wondering about this myself!

Discourse has a maximum length so that other users can easily remember your username. It’s kind of like a shorthand to your actual name.

But I agree, 20 seems a little small


@JonnyGamer You make a good point about why Discourse might have a maximum length, although you only need to start typing someone’s name and Discourse offers matches. Looking at the linked post, I think that another reason was constraints on the layout but now that full names and usernames are displayed above the post, I hope that is less of an issue than it used to be.

Hopefully one of the devs will be able to chime in :slight_smile:


Yeah I agree, maybe closer to 30

1 Like

That is very true :ok_hand:
Except trolling people can then make multiple account very easily that are really similar to the long username.

(For exceptionally long usernames, they get truncated, so after a certain amount of letters, you can see after that. Then someone could make multiple accounts, change one character, and it all gets really confusing)

On the Hopscotch Forum, we are already getting that. Trollers are created account that are the same exact as other users, except the lowercase “L” is an uppercase “i”

llllllllll - L’s

They are super similar

This is just one example

1 Like

Yeh I once had a conversation on an alt with someone and they thought it was who the alt was impersonating until I told them.

Also telling the difference between an alt and a real person can be hard

1 Like

This would be fairly easy to fix wirh a bit of custom css, I would assume. just make the font monospace.


Yeah, that makes sense:

III iii
lll LLL

You mean me :joy:


As far as I know, it is. You may see some UI breakage with extra long usernames that Discourse does not expect, though. The site setting is

max username length

and defaults to 20.

I haven’t checked the database schema to see what the absolute limit on username length as stored in the database is, though.


I, and I am sure some other people, would think that it might be a tire to type out long usernames, even with shortcuts, if there are many similar long usernames, it could take awhile to type


Looks like username maximum length is 60 characters even if it’s set greater.

I tried with settings of 127 and 254 for username lengths…


  • https://{{url}}/admin/groups
  • name: This_is_a_long_username_for_a_new_group_title_that_take_exactly_77_characters


    "errors": [
        "Name is too long"

After verification, this is related to:

cd /var/discourse/
./launcher enter app
sed -i 's/MAX_CHARS ||= 60/MAX_CHARS ||= 255/g' app/models/username_validator.rb
1 Like