1

I had a problem with my cloud server and all my sites were generating 500 errors. The response page the visitor saw varied between Craft 2, Craft 3 and ExpressionEngine 2 sites. The Craft 3 ones showed:

CDbCommand failed to execute the SQL statement: SQLSTATE[HY000]: General error: 1 Can't create/write to file '/tmp/#sql3fa0.MYI' (Errcode: 28)

Some showed what I think is the generic cPanel page:

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator at [email protected] to inform them of the time this error occurred, and the actions you performed just before this error.

More information about this error may be available in the server error log.

Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.

Others a blank page.

I now want to have a nice/useful/descriptive 500 error page shown if it happens again. So after reading up on this, in particular, the NY Studio 107 article on error pages I want to be able to test if my new 500 error page does get shown when there is a real 500 error situation.

The hosting company suggested adding a 500.html file in the public_html, adding ErrorDocument 500 /500.html to my .htaccess and creating a script file with this in it:

<?php
ini_set('display_errors', 0);
throw new Exception('Test');
?>

and calling it in the browser, but it didn't work. Their response was:

Sorry, in this case the HTTP 500 error is not caught by Apache in a way it can handle it. There are ways of doing PHP error handling in PHP, but it will depend on the application to do it for you.

Any suggestions as to how to test that it's all working properly?

1 Answer 1

1

Any chance you're out of disk space? That error shows that it can't create a file in /tmp which means either the permissions on /tmp are wrong, or potentially you're out of disk space.

c.f.: https://stackoverflow.com/questions/11997012/mysql-cant-create-write-to-file-tmp-sql-3c6-0-myi-errcode-2-what-does

As for the error page, if you just want to view the page, you can navigate to it directly... if you want to force a 500 error to happen, just change the db password in your .env to something that doesn't work.

7
  • That specific problem/error was due to an incorrect path set in php.ini. "There were many thousands of PHP sessions in the /tmp directory, causing it to be full - not on disk space (it was only 4% full there) but on the amount of files allowed on the filesystem aka the inodes".
    – Paul Frost
    Dec 22, 2018 at 16:00
  • So that problem is solved, it's now how to improve the visitor experience for next time and specifically how to test if my nice new 500 error template gets delivered correctly.
    – Paul Frost
    Dec 22, 2018 at 16:04
  • Ah that makes sense. Switch over to Redis for PHP sessions: The Case of the Missing PHP Session Dec 23, 2018 at 1:31
  • Thanks for that Andrew, but the question/problem I'm trying to resolve is how to test my 500 error page. How can I manually trigger an issue that would result in a 500?
    – Paul Frost
    Dec 23, 2018 at 9:29
  • If you just want to view the page, you can navigate to it directly... if you want to force a 500 error to happen, just change the db password in your .env to something that doesn't work. Dec 23, 2018 at 15:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.