Answers.Body: <p>Any chance you're out of disk space? That error shows that it can't create a file in <code>/tmp</code> which means either the permissions on <code>/tmp</code> are wrong, or potentially you're out of disk space.</p>
  
  <p>c.f.: <a href="https://stackoverflow.com/questions/11997012/mysql-cant-create-write-to-file-tmp-sql-3c6-0-myi-errcode-2-what-does">https://stackoverflow.com/questions/11997012/mysql-cant-create-write-to-file-tmp-sql-3c6-0-myi-errcode-2-what-does</a></p>
  
  <p>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.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-12-22T16:00:10.523Z
Answers.Text: 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".
Answers.UserDisplayName: Paul Frost
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-12-22T16:04:51.223Z
Answers.Text: 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.
Answers.UserDisplayName: Paul Frost
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-12-23T01:31:58.320Z
Answers.Text: Ah that makes sense. Switch over to Redis for PHP sessions: [The Case of the Missing PHP Session](https://nystudio107.com/blog/the-case-of-the-missing-php-session)
Answers.UserDisplayName: andrew.welch
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-12-23T09:29:02.903Z
Answers.Text: 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?
Answers.UserDisplayName: Paul Frost
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-12-23T15:55:03.953Z
Answers.Text: 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.
Answers.UserDisplayName: andrew.welch
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-12-24T09:05:32.830Z
Answers.Text: Forcing the error was what I was looking for, thanks Andrew. Seems like it's such an obvious solution but no one else suggested it.
  Do you need to edit your answer to include the solution so I can tick to accept it?
Answers.UserDisplayName: Paul Frost
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-12-24T14:01:10.900Z
Answers.Text: Edited my original answer!
Answers.UserDisplayName: andrew.welch
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-12-22T15:00:18.793Z
Answers.LastActivityDate: 2018-12-24T14:01:00.870Z
Answers.LastEditDate: 2018-12-24T14:01:00.870Z
Answers.UserDisplayName: andrew.welch
Body: <p>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:</p>
  
  <blockquote>
    <p>CDbCommand failed to execute the SQL statement: SQLSTATE[HY000]:
    General error: 1 Can't create/write to file '/tmp/#sql3fa0.MYI'
    (Errcode: 28)</p>
  </blockquote>
  
  <p>Some showed what I think is the generic cPanel page:</p>
  
  <blockquote>
    <p><strong>Internal Server Error</strong></p>
    
    <p>The server encountered an internal error or misconfiguration and was
    unable to complete your request.</p>
    
    <p>Please contact the server administrator at webmaster@scottish6days.com
    to inform them of the time this error occurred, and the actions you
    performed just before this error.</p>
    
    <p>More information about this error may be available in the server error
    log.</p>
    
    <p>Additionally, a 500 Internal Server Error error was encountered while
    trying to use an ErrorDocument to handle the request.</p>
  </blockquote>
  
  <p>Others a blank page.</p>
  
  <p>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 <a href="https://nystudio107.com/blog/handling-errors-gracefully-in-craft-cms" rel="nofollow noreferrer"> NY Studio 107 article on error pages</a> I want to be able to test if my new 500 error page does get shown when there is a real 500 error situation.</p>
  
  <p>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:</p>
  
  <pre><code>&lt;?php
  ini_set('display_errors', 0);
  throw new Exception('Test');
  ?&gt;
  </code></pre>
  
  <p>and calling it in the browser, but it didn't work. Their response was:</p>
  
  <blockquote>
    <p>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.</p>
  </blockquote>
  
  <p>Any suggestions as to how to test that it's all working properly?</p>
  
Tags: <error-message><error-templates><error-handling>
Title: How can I test my 500 error page works
ThreadText: # How can I test my 500 error page works
  
  (Asked by: username_0 on 2018-12-22)
  
  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 webmaster@scottish6days.com
  > 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](https://nystudio107.com/blog/handling-errors-gracefully-in-craft-cms) 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?
  
  **Tags:** error-message, error-templates, error-handling
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2018-12-22. Score: 1 | Accepted answer
  
  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.
  
  > **Comments:**
  > **username_0**: 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".  
  > **username_0**: 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.  
  > **username_1**: Ah that makes sense. Switch over to Redis for PHP sessions: [The Case of the Missing PHP Session](https://nystudio107.com/blog/the-case-of-the-missing-php-session)  
  > **username_0**: 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?  
  > **username_1**: 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.  
  > **username_0**: Forcing the error was what I was looking for, thanks Andrew. Seems like it's such an obvious solution but no one else suggested it. Do you need to edit your answer to include the solution so I can tick to accept it?  
  > **username_1**: Edited my original answer!  
  
  ---
  
  