HELP! Can't login to Rocket Chat [FIXED]


I had:

  1. Installed Rocket Chat using Ubuntu snap
  2. Using nginx reverse proxy from to
  3. Configured Keycloak for SSO login using oAuth

Everything was working fine for months. Just today morning after server restart, whenever I try to login to Rocket Chat, it forward me to localhost:3000

I found that Rocket Chat siteurl was set to localhost, so I changed to using:

sudo snap set rocketchat-server siteurl=

However still the issue persist.

I can see similar message in Keycloak log whenever I try to login:

2022-09-18 13:37:02,708 WARN  [] (executor-thread-134) type=CODE_TO_TOKEN_ERROR, realmId=anngo-hub,, userId=36-CODE, ipAddress=, error=invalid_code, grant_type=authorization_code, code_id=36-CODE, client_auth_method=client-secret

It seems that keycloak token given to Rocket Chat is wrong or missing but not sure how to check that if I can’t login to Rocket Chat. Is there a command line to get/set this value in Rocket Chat snap.

Didn’t find a way other than updating the mongodb directly:

db.rocketchat_settings.updateOne( { _id: "Accounts_ShowFormLogin" }, { $set : { "value" : true } } );

This update return the default RocketChat Login Form. Once I logged in, I got message says that site url is set to localhost and asks to change. So I confirmed. Disabled default login form agian and everything is back to normal.

Not sure however why the Site URL changed to localhost by itself and how to avoid this in the future?

1 Like