Mautic went down after cache clearing

Your software
My Mautic version is: V3.3.3
My PHP version is: 7.3.27
My Database type and version is: 2020.4

Your problem
My problem is: Mautic went down after cache clearing

These errors are showing in the log: This page isn’t working

Steps I have tried to fix the problem: Reinstalled Mautic 2 times, checked all database issues and fixed

Same issue here.
I’m on Mautic to latest release 4.2.1, PHP-FPM 7.4, MariaDB.

After updating everything was fine.
Then I regenerated assets and seems the dashboard is broken, JS stuck and not loading.
(screenshot here Screenshot by Lightshot)

I noticed the following errors:

Uncaught ReferenceError: Mousetrap is not defined
at Object.addKeyboardShortcut (app.js:9:241)
at Object.bindGlobalKeyboardShortcuts (app.js:10:173)
at Object.Mautic.onPageLoad (app.js:83:57)
at dashboard:513:20

I have reinstalled the package, reset permissions, cleared cache multiple times, but doesn’t seem to come up.
To navigate through the menu I need to manually edit the URL.

For now it seems I’ve fixed it by rolling back to 4.2 and NOT changing user:group to the Mautic folder (so I’ve got a mix of root and mautik permissions).

Hi, this comes up often, you should check who is running the webserver.
Here is a comprehensive guide covering cache, permissions and assets.

1 Like


Horraayy! Thanks for the article! That was very helpful, but what can I do with the server now? Shall I reinstall or any other solutions?

Brilliant!
Well done and thanks for taking time writing this down.

My only concern is this:
‘That is the equivalent of running around with two active nuclear warheads ducktaped to your arms in a porcelaine store while walking on lego blocks’.

If you hear a blast it might have been my sudo user.

Lol :slight_smile: careful. Great power comes with great responsibiliy.

You confused me now. Did it work or not?

Cache for the prod environment was successfully warmed but Mautic still down, so probably didn’t work, what shall I do?

Hi, I am real noob, so apologies if this is dumb, but is it because these commands are reversed in Joeyk’s otherwise excellent guide?

find . -type f -not -perm 644 -exec chmod 644 {} +
find . -type d -not -perm 755 -exec chmod 755 {} +

ie should be

find . -type d -not -perm 644 -exec chmod 644 {} +
find . -type f -not -perm 755 -exec chmod 755 {} +


nothing changed, what to do next?

can you do an

ls -la


next?

You are fine here, we should see your apache / nginx log.


No such file or directory, how to find it?

I think we can be more productive. Any chance you can come today 30 min earlier to the Mautic Meetup?

Then I could take a look.

Yes, sure! I’ll come 30 minute earlier :+1:


I was waiting here, will it start earlier?

Dropped you PM

Hello!

Thanks one more time for your help! Can you send me as a text how to avoid this to happen again please? How I understood yesterday I need to install a SSL, because people coming to the page and they want to use SSL and there’s no valid one and it looked like person with expired ID. So, need to install SSL and you can send me some commands which will be helpful to do it.

Also, how I understood steps are like that (correct me or write me the right explanation please):

  1. Note for myself: don’t clear a cache with php bin/console cache:clear

And this is because of the permissions. So there is one virtual user who is responsible for running the web-show. ps aux | egrep ‘nginx’ and this user runs my webserver most likely apache or nginx.

  1. When I tried to actually see what the name of this virtual user is. and I tried:

ps aux | egrep ‘(apache|httpd)’ So when I regerate my cache and run the php bin/console cache:clear command NOT as the www-data user, but for example sudo user I can run into problems. Sudo is the post powerful user on the server, and this command is the equvalent of the hotel director rewriting all the recipes, but not letting in anyone into the kitchen under his ranks.

  1. Don’t just update or clear the cache in the name of any user. Especially if I am logged in as sudo. Even if I am sudo user, you can issue the commands as www-data user by using this format: sudo -u www-data php /var/www/html/mautic/app/console cache:clear
  2. Once my permissions are already messed up, I can try any time fix it. Go to your Mautic folder, and:

find . -type f -not -perm 644 -exec chmod 644 {} +

find . -type d -not -perm 755 -exec chmod 755 {} +

chmod -R g+w var/cache/ var/logs/ app/config/

chmod -R g+w media/files/ media/images/ translations/

rm -rf var/cache/*

This is like a general fix, I can run any time I have an issue with “unable to write” or “cannot be found” type of errors. I can also regerate the cache by warming it up: sudo -u www-data php bin/console cache:warmup

It gave me a nice green output, which means that everything should be okay:

“Cache for the “prod” environment (debug=false) was successfully warmed.”

  1. Symfony also works with assets. These are not inclided in the cache, and I might need to regenerate them from time to time, after update when big changes have happened in the background. This solves issues like previously working fictions not working, like dropdown in segments. So Issued the right command: sudo -u www-data php bin/console mautic:assets:generate
  2. So my steps combined and minifed asset files from each bundle into single production files. In other words: reseted big changes. But server was still down. I fixed permission issue with sudo chown -R www-data:www-data. And sudo chmod -R 775
  3. Afterwards cd app/config ; and we deletes S in https site url
  4. Cleared cache with rm -rf var/cache/*
    I forgot what commands we used to open GNO nano5.4 and why we deleted S and why it caused a problem?