Getting a session mismatch every time the page reloads.

General Discussion
  • I'm getting a session mismatch error every time the page reloads. It's impossible to login to my forum.

    • Check in config.json that the url of your forum matches exectly the domain url you are using
    • Disable nginx routing for a test and access your forum directly to see if it helps
    • If you use Cloudfare disable Cloudfare distribution unless you have a higher plan which allows websockets
    • Check with/without firewall
    • I did a manual npm re-install which may have fixed something, too

    I have been trough this frustrating experience for days but in the end got it all sorted. Its quite a bit of learning to get it working but in the end it all makes sense.

  • The common causes for a session mismatch error are usually one of the following:

    1. Mis-configured URL parameter in your config.json file

    If you have a misconfigured url value in your config.json file, the cookie may be saved incorrectly (or not at all), causing a session mismatch error. Please ensure that the link you are accessing your site with and the url defined match.

    2. Improper/malformed cookieDomain set in ACP

    Sometimes admins set this value without realising that they probably don't need to set it at all. The default is perfectly fine. This is what the config looks like:

    Cookie Domain setting

    If this is set, you'll want to revert the setting by editing your database directly:

    Redis: hdel config cookieDomain
    MongoDB: db.objects.update({ _key: "config" }, { $set: "cookieDomain": "" });

    3. Missing X-Forwarded-Proto header from nginx/apache

    If you are using a reverse proxy, you will need to have nginx pass a header through to NodeBB so it correctly determines the correct cookie secure property.

    In nginx, you will need to add the directive like so:

    location / {
        proxy_set_header X-Forwarded-Proto $scheme;
  • @julian after trying to set cookiedomain in MongoDB with your command I get:

    2018-05-31T16:16:42.444+0000 E QUERY [thread1] SyntaxError: missing } after property list @(shell):1:60

  • db.objects.update({ _key: "config" }, { $set: { "cookieDomain": "" } });

    My bad, forgot some curly braces 🙂

Suggested Topics