{"id":795,"date":"2024-04-10T22:06:07","date_gmt":"2024-04-10T22:06:07","guid":{"rendered":"https:\/\/www.cmsgalaxy.com\/blog\/?p=795"},"modified":"2024-06-30T09:55:58","modified_gmt":"2024-06-30T09:55:58","slug":"drupal-troubleshooting-guide","status":"publish","type":"post","link":"https:\/\/www.cmsgalaxy.com\/blog\/drupal-troubleshooting-guide\/","title":{"rendered":"Drupal Troubleshooting Guide"},"content":{"rendered":"\n<h3 class=\"wp-block-heading\">1. <strong>Watchdog Database Logs<\/strong><\/h3>\n\n\n\n<p>Drupal logs errors in the database using the Watchdog module, which is enabled by default. If you have access to the database via a tool like phpMyAdmin or command line access via MySQL client, you can query the Watchdog table directly.<\/p>\n\n\n\n<p>To see the most recent log messages, you can run the following SQL query:<\/p>\n\n\n\n<p><code>SELECT * FROM watchdog ORDER BY wid DESC LIMIT 50;<\/code><\/p>\n\n\n\n<p>This query selects the last 50 entries in the Watchdog table. The <code>message<\/code> and <code>variables<\/code> columns will contain error information, though the <code>variables<\/code> column is serialized and may need to be unserialized to be human-readable.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">2. <strong>PHP Error Logs<\/strong><\/h3>\n\n\n\n<p>Since you&#8217;re using XAMPP, PHP&#8217;s error logs are another valuable resource for diagnosing an HTTP 500 error. By default, PHP errors might be logged to a file named <code>php_error_log<\/code> in the <code>php<\/code> directory within your XAMPP installation (<code>\/opt\/lampp\/logs\/<\/code>). This location can vary based on your PHP configuration (<code>php.ini<\/code>), where the <code>error_log<\/code> directive is set.<\/p>\n\n\n\n<p>Open this log file with a text editor or use the <code>tail<\/code> command to view the last few entries:<\/p>\n\n\n\n<p><code>tail -n 100 \/opt\/lampp\/logs\/php_error_log<\/code><\/p>\n\n\n\n<p>This command displays the last 100 lines of the log file, where you might find errors related to your issue.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">3. <strong>Apache Error Logs<\/strong><\/h3>\n\n\n\n<p>Apache also logs errors, and these logs can provide details on what&#8217;s causing the 500 Internal Server Error. For a XAMPP installation, Apache&#8217;s error logs are typically located at <code>\/opt\/lampp\/logs\/error_log<\/code>.<\/p>\n\n\n\n<p>You can view the most recent entries with:<\/p>\n\n\n\n<p><code>tail -n 100 \/opt\/lampp\/logs\/error_log<\/code><\/p>\n\n\n\n<p>Look for entries that correspond to the time the error occurred; they might give you specifics about what went wrong.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">4. <strong>Enable Verbose PHP Error Reporting Temporarily<\/strong><\/h3>\n\n\n\n<p>If the logs are not showing enough detail, you can temporarily increase the verbosity of PHP error reporting by modifying the <code>php.ini<\/code> file (<code>\/opt\/lampp\/etc\/php.ini<\/code>) and setting:<\/p>\n\n\n\n<p><code>display_errors = On error_reporting = E_ALL log_errors = On<\/code><\/p>\n\n\n\n<p>Remember to restart Apache after making these changes for them to take effect. This might provide more detailed errors directly in your browser or in the PHP error log.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">5. <strong>Drupal&#8217;s <code>settings.php<\/code><\/strong><\/h3>\n\n\n\n<p>Lastly, ensure Drupal&#8217;s <code>settings.php<\/code> is configured to log errors by checking these settings:<\/p>\n\n\n\n<p><code>$conf['error_level'] = 2; \/\/ Show all messages on your site<\/code><\/p>\n\n\n\n<p><code>ini_set('display_errors', TRUE); <\/code><\/p>\n\n\n\n<p><code>ini_set('display_startup_errors', TRUE);<\/code><\/p>\n\n\n\n<p>This is particularly useful during development but should be used with caution on live sites.<\/p>\n\n\n\n<p>By checking these logs and settings, you should be able to identify the cause of the HTTP ERROR 500 on your Drupal site.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">6. <strong>Debugging Drupal:<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Enable Drupal debugging:<\/strong> You can enable error reporting in Drupal by editing the <code>sites\/default\/settings.php<\/code> file and adding or updating these lines:<\/li>\n\n\n\n<li><code>$config['system.logging']['error_level'] = 'verbose'; \/\/ Drupal 8 and later <\/code>This might allow Drupal to display more detailed error messages on the screen or in its own logs.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">7. How to enable verbose mode in Drupal<\/h2>\n\n\n\n<p>ou can temporary activate display of all errors by adding the next lines in your&nbsp;<code>sites\/default\/settings.php<\/code>&nbsp;file:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ Show all errors.\n$config&#91;'system.logging']&#91;'error_level'] = 'verbose';\nerror_reporting(E_ALL);\nini_set('display_errors', TRUE);\nini_set('display_startup_errors', TRUE);<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">8. Manually Clear Cache<\/h3>\n\n\n\n<p>If Drush remains unresponsive and you need to clear your Drupal cache, you can do so manually through the database. This method requires access to your database via a tool like phpMyAdmin or command line.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Using MySQL Command Line:<\/strong>\n<ol class=\"wp-block-list\">\n<li>Log in to your MySQL database: <code>mysql -u yourusername -p yourdatabase<\/code><\/li>\n\n\n\n<li>Run the following SQL command to clear the cache tables: <code>DELETE FROM cache; <\/code>Repeat this command for other cache tables (<code>cache_render<\/code>, <code>cache_data<\/code>, etc.), as needed.<\/li>\n<\/ol>\n<\/li>\n\n\n\n<li><strong>Using phpMyAdmin:<\/strong>\n<ol class=\"wp-block-list\">\n<li>Open phpMyAdmin and select your Drupal database.<\/li>\n\n\n\n<li>Browse each <code>cache<\/code> table (<code>cache<\/code>, <code>cache_render<\/code>, <code>cache_data<\/code>, etc.).<\/li>\n\n\n\n<li>Use the &#8220;Empty&#8221; (or &#8220;Truncate&#8221;) option to clear the cache from each table.<\/li>\n<\/ol>\n<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>1. Watchdog Database Logs Drupal logs errors in the database using the Watchdog module, which is enabled by default. If<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[790],"tags":[],"class_list":["post-795","post","type-post","status-publish","format-standard","hentry","category-drupal"],"_links":{"self":[{"href":"https:\/\/www.cmsgalaxy.com\/blog\/wp-json\/wp\/v2\/posts\/795","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.cmsgalaxy.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.cmsgalaxy.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.cmsgalaxy.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.cmsgalaxy.com\/blog\/wp-json\/wp\/v2\/comments?post=795"}],"version-history":[{"count":4,"href":"https:\/\/www.cmsgalaxy.com\/blog\/wp-json\/wp\/v2\/posts\/795\/revisions"}],"predecessor-version":[{"id":800,"href":"https:\/\/www.cmsgalaxy.com\/blog\/wp-json\/wp\/v2\/posts\/795\/revisions\/800"}],"wp:attachment":[{"href":"https:\/\/www.cmsgalaxy.com\/blog\/wp-json\/wp\/v2\/media?parent=795"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.cmsgalaxy.com\/blog\/wp-json\/wp\/v2\/categories?post=795"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.cmsgalaxy.com\/blog\/wp-json\/wp\/v2\/tags?post=795"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}