4

Some of my users that use Google Chrome or Firefox experience an Internal Server Error, once they clear their cache for my website, the error disappears. I had this issue over a year ago but switching to a different hoster "fixed" it, but now the issue has come back.

Here is what recently was done (not sure if any one, all or none of these caused it):

  • Upgraded CakePHP (from 2.8.9 to 2.10.7)
  • Changed PHP Config from php5.6 as default + CLI and php7.0 dedicated for Web role to php 7.0 for everything (this was necessary to prevent the sockets of the fpm processes to collide and crash the server on a restart)

Of course I can tell my users to clear their cache, but I would also like to understand what might cause this or what potential could cause this behaviour (it's really hard to debug as only some users are affected).

Christian Strang
  • 8,470
  • 5
  • 42
  • 53
  • 4
    If it's a server error check your logs and if you don't have any enable logging. Asking this question here is more or less pointless without having more than saying that a server error happens, it could be anything. It's something with the environment if it was not happening before and your environment has changed. – floriank Feb 19 '18 at 16:35

2 Answers2

3

1 - Check your logs. If there aren't any error logs then enable logging on your servers. Check out https://book.cakephp.org/3.0/en/core-libraries/logging.html to use CakePHP logging, or check documentation for your server to enable logging on your server.

2 - You can try to use a try/catch block to echo the error out to the user, who can then give you a more specific error message. Go into the main PHP file and wrap all the contents in

try { 
  ...... (your PHP code here) ......
} catch(Exception $e) {
   die($e->getMessage());
}

If the error is related to an Exception that PHP can catch, the error message will be echoed out to the user. If you don't want to echo it out to the user (there may be some security concerns) then you can write $e->getMessage() to a log file so that only you can see it.

shadowfox
  • 505
  • 4
  • 7
1

Seems to be an error with PHP sessions:

  • It is fixed when users clear their cookies and may be occurs when the PHP version is updated.

  • Some session errors only occurs after determinated time and could be more randomly.

  • It could occurs in any point of your code (this can do the debug more dificult!).

  • Fixed when you change the hosting.(New server implies new or default session config)

    Revise your PHP session configuration and your CakePHP session config (may be add it to the question could helps). ¿Are you using Memcached or similar?

Community
  • 1
  • 1
Martin
  • 1,282
  • 1
  • 15
  • 43
  • Yes, I'm using Memcached (I might have used it on the previous hoster as well, though I'm not 100% sure I did). – Christian Strang Feb 28 '18 at 14:39
  • Check that you have correctly configured php to use memcached. Pay attention if you are using "memcached" or "memcache" (they are different tools). I had a similar error after installing memcached and configuring php to use memcache. One easy mode to check if this is the error is change session configuration to default mode some days. – Martin Feb 28 '18 at 18:30