mauticcsrf-token

CSRF in Mautic - Invalid CSRF Token Error


I get this error every time I try to do anything in Mautic, e.g. Save a form, change password, etc. I have just migrated and updated Mautic into a new environment, based on the official mautic/mautic image from Dockerhub. I also changed the domain name.

Correct error message: CSRF token error. Try to refresh the page and try again.

Here are some things I've tried to fix this:

  1. Clear cache
  2. Change username and password of the admin user, clear cache
  3. Added session.save_path = /var/php_sessions/ to php.ini, clear cache
  4. Delete browser cookies, clear cache
  5. php app/console mautic:update:find
  6. php app/console mautic:update:apply
  7. php app/console doctrine:migration:status
  8. php app/console doctrine:migration:migrate
  9. php app/console doctrine:schema:update --dump-sql
  10. php app/console doctrine:schema:update --env=prod --force
  11. php app/console cache:clear * 1000 times
  12. Checked mymautic.com/s/sysinfo for error messages(fixed all errors)
  13. Checked folder permissions, all green in the Folder & File Permissions tab
  14. Delete cache directory

Yes, kind of some tricks ol' Google tipped me about. Now I'm out of ideas. Or maybe 2 ideas left, because I changed the domain name, the CSRF-token is not happy :( how do I fix?

Or, Because I'm using Nginx as a loadbalancer so that the CSRF token gets lost on the way(But I was using the same setup before 🤔).

Been trying to solve this for like 5 hours now, going mad. Gonna take a break from that now and hopefully some fellow stackoverflower has some nice brainstorming ideas.


Solution

  • Ok, I found my error. After migrating I accidentally overwrote the new media/js/app.js with the old one. 🤦🏻‍♂️