{"id":8623,"date":"2023-03-16T15:27:16","date_gmt":"2023-03-16T15:27:16","guid":{"rendered":"https:\/\/www.geekdecoder.com\/?p=8623"},"modified":"2023-03-16T15:27:16","modified_gmt":"2023-03-16T15:27:16","slug":"apache-error-codes","status":"publish","type":"post","link":"https:\/\/www.qbytes.cloud\/index.php\/2023\/03\/16\/apache-error-codes\/","title":{"rendered":"Apache Error Codes"},"content":{"rendered":"\n<p>Apache error codes are three-digit numbers returned by the Apache web server when something goes wrong during the processing of HTTP requests. <\/p>\n\n\n\n<!--more-->\n\n\n\n<p>Some common Apache error codes include:<\/p>\n\n\n\n<p>200 \u2013 OK<br>A 200 response code means the connection has been successful and the browser will serve the websites content.<\/p>\n\n\n\n<p>You can see these in the access log files.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: java; title: ; notranslate\" title=\"\">\n143.244.42.95 - - &#x5B;16\/Mar\/2023:15:21:48 +0000] &quot;GET \/ HTTP\/1.0&quot; 200 109196 &quot;http:\/\/mydomain.io\/&quot; &quot;Mozilla\/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/90.0.4430.93 Safari\/537.36&quot;\n<\/pre><\/div>\n\n\n<p><\/p>\n\n\n\n<p>206 \u2013 Partial Content<br>This code explains that the connection is only requesting parts of the website such as just the code with a wget command, this code can be fairly common.<\/p>\n\n\n\n<p>301 \u2013 Moved Permanently<br>This code lets the browser know that the url has been moved permanently to a new location and to forward all future request to the new location.<\/p>\n\n\n\n<p>302 \u2013 Moved Temporarily<br>This code is very similar to 301 but instead of a permanent move, it is temporary.<\/p>\n\n\n\n<p>303 \u2013 See Other<br>This code is a way to redirect web applications to a new URL.<\/p>\n\n\n\n<p>304 \u2013 Not Modified<br>This indicates that the browser has a cached copy of the website and the website has not had any modications since the browsers last visit.<\/p>\n\n\n\n<p>400 \u2013 Bad Request<br>The server is not able to process the clients request due to something wrong with the client (e.g., malformed request syntax, invalid request message framing, or deceptive request routing).<\/p>\n\n\n\n<p>401 \u2013 Unauthorized<br>Similar to 403 Forbidden, but specifically for when authentication is required to continue to the website.<\/p>\n\n\n\n<p>403 \u2013 Forbidden<br>The request was valid, however the server is refusing the connection due to configuration settings.<\/p>\n\n\n\n<p>404 \u2013 Not Found<br>The file requested resource could not be found but may be available again in the future. You might also run into a few other error codes that convey the same thing. Common variants include \u201cPage Not Found\u201d or \u201cFile Not Found.\u201d Depending on which website you\u2019re browsing, you might also see messages like &#8220;Product not Found.&#8221;<\/p>\n\n\n\n<p>So, let\u2019s take a look at some things you can do to try to fix a 404 error. In most cases, it\u2019s likely that the page you\u2019re looking for was moved or deleted. But, you can try this on the client end.<\/p>\n\n\n\n<p>Refresh the Page<br>Double Check the Address<br>Perform a Search<br>Clear Your Browser Cache<br>Change your DNS Server<br>Check if the Website Has Temporary Issues<\/p>\n\n\n\n<p>405 \u2013 Method Not Allowed<br>A request was made to the website which was different than it was programmed to handle such as using GET on a form which requires data to be presented via POST, or using PUT on a read-only resource.<\/p>\n\n\n\n<p>406 \u2013 Not Acceptable<br>This code means that the server has blocked the request via mod_security.<\/p>\n\n\n\n<p>413 \u2013 Request Entity Too Large<br>The request is larger than the server is willing or able to process.<\/p>\n\n\n\n<p>500 \u2013 Internal Server Error<br>This error is generally specific to something written in the .htaccess file that is not valid syntax or the website file permissions are in correct.<\/p>\n\n\n\n<p>501 \u2013 Not Implemented<br>The server was not programmed to handle the type of request, or it was not able to fulfill the request.<\/p>\n\n\n\n<p>Now that we have the codes, let&#8217;s take a look at how to check for errors.<\/p>\n\n\n\n<p>The commands that you will commonly use to troubleshoot Apache across most Linux distributions are:<\/p>\n\n\n\n<p>systemctl &#8211; Used to control and interact with Linux services via the systemd service manager.<br>journalctl &#8211; Used to query and view the logs that are generated by systemd.<br>apachectl &#8211; When troubleshooting, this command is used to check Apache\u2019s configuration.<\/p>\n\n\n\n<p>Generally when you are troubleshooting Apache, you will use these commands in the order indicated here, and then examine log files for specific diagnostic data.<\/p>\n\n\n\n<p><code>systemctl <\/code>Commands for Apache<\/p>\n\n\n\n<p>On Ubuntu and Debian.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: java; title: ; notranslate\" title=\"\">\nsudo systemctl status apache2.service -l --no-pager\n<\/pre><\/div>\n\n\n<p>The&nbsp;<code>-l<\/code>&nbsp;flag will ensure that output is not truncated or ellipsized. The&nbsp;<code>--no-pager<\/code>&nbsp;flag will make sure that output will go directly to your terminal without requiring any interaction on your part to view it.<\/p>\n\n\n\n<p>Output<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n\u25cf apache2.service - The Apache HTTP Server\n     Loaded: loaded (\/lib\/systemd\/system\/apache2.service; enabled; vendor preset: enabled)\n     Active: active (running) since Tue 2023-03-14 15:14:14 CDT; 1 day 18h ago\n       Docs: https:\/\/httpd.apache.org\/docs\/2.4\/\n    Process: 577 ExecStart=\/usr\/sbin\/apachectl start (code=exited, status=0\/SUCCESS)\n    Process: 7904 ExecReload=\/usr\/sbin\/apachectl graceful (code=exited, status=0\/SUCCESS)\n   Main PID: 606 (apache2)\n      Tasks: 6 (limit: 2337)\n     Memory: 36.8M\n        CPU: 9.846s\n     CGroup: \/system.slice\/apache2.service\n             \u251c\u2500 606 \/usr\/sbin\/apache2 -k start\n             \u251c\u25007909 \/usr\/sbin\/apache2 -k start\n             \u251c\u25007910 \/usr\/sbin\/apache2 -k start\n             \u251c\u25007911 \/usr\/sbin\/apache2 -k start\n             \u251c\u25007912 \/usr\/sbin\/apache2 -k start\n             \u2514\u25007913 \/usr\/sbin\/apache2 -k start\n\nMar 14 15:14:12 my.hostname.io systemd&#x5B;1]: Starting The Apache HTTP Server...\n<\/pre><\/div>\n\n\n<p>To inspect the Apache process on CentOS and Rocky systems run:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: java; title: ; notranslate\" title=\"\">\nsudo systemctl status httpd.service -l --no-pager\n<\/pre><\/div>\n\n\n<p>Make a note of the &#8220;Active line&#8221; in the output. If your Apache server does not show active (running) there may be an error. If there is a problem, you will have a line like the following in your output (note the highlighted failed portion):<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nActive: failed (Result: exit-code) since Tue 2020-07-14 20:01:29 UTC; 1s ago\n<\/pre><\/div>\n\n\n<p>If there is an error it may look like the following:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n\u25cf apache2.service - The Apache HTTP Server\n     Loaded: loaded (\/lib\/systemd\/system\/apache2.service; enabled; vendor preset: enabled)\n     Active: failed (Result: exit-code) since Thu 2023-03-16 10:15:04 CDT; 1min 7s ago\n       Docs: https:\/\/httpd.apache.org\/docs\/2.4\/\n    Process: 9835 ExecStart=\/usr\/sbin\/apachectl start (code=exited, status=1\/FAILURE)\n        CPU: 23ms\n\nMar 16 10:15:04 my.hostname.io systemd&#x5B;1]: Starting The Apache HTTP Server...\nMar 16 10:15:04 my.hostname.io apachectl&#x5B;9838]: AH00526: Syntax error on line 93 of \/etc\/apache2\/apache2.conf:\nMar 16 10:15:04 my.hostname.io apachectl&#x5B;9838]: Invalid command &#039;Time&#039;, perhaps misspelled or defined by a module not included in the server configuration\nMar 16 10:15:04 my.hostname.io apachectl&#x5B;9835]: Action &#039;start&#039; failed.\nMar 16 10:15:04 my.hostname.io apachectl&#x5B;9835]: The Apache error log may have more information.\nMar 16 10:15:04 my.hostname.io systemd&#x5B;1]: apache2.service: Control process exited, code=exited, status=1\/FAILURE\nMar 16 10:15:04 my.hostname.io systemd&#x5B;1]: apache2.service: Failed with result &#039;exit-code&#039;.\nMar 16 10:15:04 my.hostname.io systemd&#x5B;1]: Failed to start The Apache HTTP Server.\n\n<\/pre><\/div>\n\n\n<p>From here we can see the error and correct it:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nMar 16 10:15:04 my.hostname.io apachectl&#x5B;9838]: AH00526: Syntax error on line 93 of \/etc\/apache2\/apache2.conf:\n<\/pre><\/div>\n\n\n<p><code>journalctl<\/code>&nbsp;Commands for Apache<\/p>\n\n\n\n<p>To inspect the&nbsp;<code>systemd<\/code>&nbsp;logs for Apache, you can use the&nbsp;<code>journalctl<\/code>&nbsp;command. The&nbsp;<code>systemd<\/code>&nbsp;logs for Apache will usually indicate whether there is a problem with starting or managing the Apache process.<\/p>\n\n\n\n<p>These logs are separate from Apache\u2019s request and error logs.&nbsp;<code>journalctl<\/code>&nbsp;displays logs from&nbsp;<code>systemd<\/code>&nbsp;that describe the Apache service itself, from startup to shutdown, along with any process errors that may be encountered along the way.<\/p>\n\n\n\n<p>On Ubuntu and Debian <\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nsudo journalctl -u apache2.service --since today --no-pager\n<\/pre><\/div>\n\n\n<p>The&nbsp;<code>--since today<\/code>&nbsp;flag will limit the output of the command to log entries beginning at 00:00:00 of the current day only. Using this option will help restrict the volume of log entries that you need to examine when checking for errors. You should receive output like the following:<\/p>\n\n\n\n<p>Output for a successful start<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nJournal file \/var\/log\/journal\/6639af0b46c646bea8905dc9470e5494\/system@0005f4acc1d412c5-8cf425b3c42a967e.journal~ is truncated, ignoring file.\n-- Journal begins at Fri 2022-09-23 21:48:54 CDT, ends at Thu 2023-03-16 09:56:58 CDT. --\nMar 16 00:00:41 my.hostname.io systemd&#x5B;1]: Reloading The Apache HTTP Server.\nMar 16 00:00:41 my.hostname.io systemd&#x5B;1]: Reloaded The Apache HTTP Server.\n<\/pre><\/div>\n\n\n<p>If you are using a CentOS or Fedora based system, use this version of the command:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: java; title: ; notranslate\" title=\"\">\nsudo journalctl -u httpd.service --since today --no-pager\n<\/pre><\/div>\n\n\n<p>Output<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nJul 14 20:13:09 centos8 systemd&#x5B;1]: Starting The Apache HTTP Server...\n. . .\nJul 14 20:13:10 centos8 httpd&#x5B;21591]: Server configured, listening on: port 80\n<\/pre><\/div>\n\n\n<p>If there is an error, you will have a line in the output that is similar to the following:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nMar 16 10:15:04 centos8 systemd&#x5B;1]: Failed to start The Apache HTTP Server.\n<\/pre><\/div>\n\n\n<p>If your Apache server has errors in the journalctl logs the next step to troubleshoot using the apachectl command line tool.<\/p>\n\n\n\n<p><code>apachectl<\/code><\/p>\n\n\n\n<p>Run the command like this on Ubuntu, Debian, CentOS, and Fedora based distributions:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nsudo apachectl configtest\n<\/pre><\/div>\n\n\n<p>Output for success<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nSyntax OK\n<\/pre><\/div>\n\n\n<p>If there is an error in your Apache configuration, apachectl will detect it and attempt to notify you.<\/p>\n\n\n\n<p>Here is an error for example:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nAH00526: Syntax error on line 93 of \/etc\/apache2\/apache2.conf:\nInvalid command &#039;Time&#039;, perhaps misspelled or defined by a module not included in the server configuration\nAction &#039;configtest&#039; failed.\nThe Apache error log may have more information.\n<\/pre><\/div>\n\n\n<p>In this example the there is a Syntax error on line 93 of \/etc\/apache2\/apache2.conf.<\/p>\n\n\n\n<p>Apache Log Files<\/p>\n\n\n\n<p>The log files are a goldmine for information.<\/p>\n\n\n\n<p>For errors on a Fedora, CentOS, or RedHat server, examine the \/var\/log\/httpd\/error_log file.<\/p>\n\n\n\n<p>For Debian or Ubuntu derived system, examine \/var\/log\/apache2\/error.log for errors.<\/p>\n\n\n\n<p>Use &#8220;tail&#8221; to view logs:<\/p>\n\n\n\n<p>Tail Examples<\/p>\n\n\n\n<p>Tail the log in real time allow you to load the page to see the errors live.<\/p>\n\n\n\n<p>Debian or Ubuntu<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: java; title: ; notranslate\" title=\"\">\nsudo tail -f \/var\/log\/apache2\/error.log\n<\/pre><\/div>\n\n\n<p>View the last 5 lines:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nsudo tail -n 5 \/var\/log\/apache2\/error.log\n<\/pre><\/div>\n\n\n<p>On CentOS or Rocky<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: java; title: ; notranslate\" title=\"\">\nsudo tail -f \/var\/log\/httpd\/error_log\n<\/pre><\/div>\n\n\n<p>View the last 5 lines:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nsudo tail -n 5 \/var\/log\/httpd\/error_log\n<\/pre><\/div>\n\n\n<p>Read the information to see if there is a specific error.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Apache error codes are three-digit numbers returned by the Apache web server when something goes wrong during the processing of HTTP requests.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-8623","post","type-post","status-publish","format-standard","hentry","category-apache"],"_links":{"self":[{"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/posts\/8623","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/comments?post=8623"}],"version-history":[{"count":0,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/posts\/8623\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/media?parent=8623"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/categories?post=8623"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/tags?post=8623"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}