From MoodleDocs
Jump to:navigation, search
This page is for any Moodle admins or developers who want to setup or customize error pages on their Moodle site. There is a variety of ways different errors can happen at different layers in a Moodle stack and because they each happen under different circumstance there cannot be a single way of handling them.
404 Normal Moodle errors and exceptions
These types of errors are things like you tried to access a course which no longer exists, or access a course which you don’t have access to. Because these are «Moodle» pages they are themed correctly and normally there isn’t much you want to do to improve them.
If you want to change the wording of the errors see:
https://docs.moodle.org/en/Language_customisation
If you want to change the theme, that is one and the same as normal theme customization:
https://docs.moodle.org/dev/Themes_overview
If a Moodle page throws an exception which isn’t captured and results in an error page, and it will also helpfully, but blindly, link into this Moodle wiki where you might find more information on the error. This is great for sites in development or for admin type errors but typically less useful. You may want to divert users to your own support instead of off into a wiki page with generic Moodle information.
This links behavior can be changed and removed in your admin settings here:
/admin/settings.php?section=documentation
https://docs.moodle.org/dev/Exceptions
You can also simply hide the links using a capability too:
https://docs.moodle.org/38/en/Linking_Moodle_and_Docs#Removing_Moodle_Docs_links_for_teachers
403 Forbidden — Web server errors
For additional security you should not allow access to directory listings and you can also block access to certain files.
For more security you can serve a 404 instead of a 403, and if you prefer you can reuse the themed 404 page below.
403 in Apache
DirectoryIndex disabled Options -Indexes ErrorDocument 403 /error/index.php
https://httpd.apache.org/docs/2.4/mod/mod_dir.html#directoryindex
403 in Nginx
error_page 403 = /error/index.php?code=404
If you want to transform all 403 errors into 404’s then:
error_page 403 = /error/index.php?code=404
Note the ‘=’ char above is important as it allows Moodle to reset the http headers to correctly serve the page in all cases.
404 File not found — Web server errors
These are for errors which are technically outside of moodle such a 404 file not found at the server level rather than a 404 served by moodle. If you want to theme these then the approach is the same as you normally would for anything non Moodle, configure your web server to show a custom error page. But instead of writing your own, there is a built in Moodle error handler php script so they get the normal Moodle theme applied. You can see an example of what this error page looks like here:
https://moodle.org/errors/
404 in Apache
You can configure this using:
ErrorDocument 404 /error/index.php
404 in nginx
error_page 404 = /error/index.php
Note the ‘=’ char above is important as it allows Moodle to reset the http headers to correctly serve the page in all cases.
502 Bad Gateway — Proxy / CDN issues
This means some upstream of your moodle server could not connect, ie nginx, varnish, a load balancer, proxy or CDN.
These error pages cannot be themed by at the application level and how to customize them depends on what is proxying moodle.
NOTE: It is very important if you do customize these to make sure you are not overriding the 40x and 50x error pages that Moodle may serve.
503 Service unavailable — Fatal Moodle bootstrap errors
New in 4.0
These types of errors are more fundamental, and something has gone wrong so Moodle itself can’t load, which means the error page can’t access the database, MUC, or the language and strings API.
Previously these were difficult to style, and there are many edge cases to capture. This was fixed in this tracker:
https://tracker.moodle.org/browse/MDL-56041
These low level error pages resulted in the ‘yellow box’ and in 4.0 are now improved to more closely match the boost / bootstrap theme. You can customize this error page by editing this file:
error/plainpage.php
Note: this file cannot contain any Moodle API’s and cannot link to files which are served by moodle such as theme files or plugin files. Ideally serve all dependencies such as css and even image inline.
503 Moodle under maintenance — Maintenance mode
During maintenance mode Moodle will serve a «503 Service Unavailable». This page can be customized:
https://docs.moodle.org/38/en/Maintenance_mode#CLI_maintenance_mode
- Remove From My Forums
-
Question
-
User676083308 posted
Here is the log file:
DownloadManager Information: 0 : Downloading file ‘http://download.moodle.org/download.php/direct/windows_wpi/MoodleWindowsWpi-latest-19-20101124.zip’ to: C:UsersrrruedAppDataLocalTemp2tmp43F1.tmp
DownloadManager Information: 0 : Starting EXE command for product ‘Windows Cache Extension 1.1 for PHP 5.2’. Commandline is: ‘C:Windowssysnativeiisreset.exe /STOP’. Process Id: 3780
DownloadManager Information: 0 : http://download.moodle.org/download.php/direct/windows_wpi/MoodleWindowsWpi-latest-19-20101124.zip
responded with 404
DownloadManager Information: 0 : Response headers:
HTTP/1.1 404 Not Found
Date: Fri, 13 May 2011 15:09:36 GMT
Server: Apache/2.2.3 (CentOS)
X-Powered-By: PHP/5.1.6
Set-Cookie: MoodleSessionDWNLD=rrvqh5ltivet8kf568foga6u45; path=/
Expires:
Cache-Control: private, pre-check=0, post-check=0, max-age=0
Pragma: no-cache
Set-Cookie: MoodleSessionTestDWNLD=5l86YwsnyV; path=/
Content-Script-Type: text/javascript
Content-Style-Type: text/css
Content-Language: en
Accept-Ranges: none
Connection: close
Transfer-Encoding: chunked
Content-Type: text/html; charset=utf-8DownloadManager Error: 0 : Error while downloading file ‘http://download.moodle.org/download.php/direct/windows_wpi/MoodleWindowsWpi-latest-19-20101124.zip’. Exception: System.InvalidOperationException: Url
‘http://download.moodle.org/download.php/direct/windows_wpi/MoodleWindowsWpi-latest-19-20101124.zip’ returned HTTP status code: 404
at Microsoft.Web.PlatformInstaller.ManagedWinInet.OpenUrlAndFollowRedirects(Uri& uri, IntPtr& hInetFile)
at Microsoft.Web.PlatformInstaller.ManagedWinInet.DownloadFile(Uri uri, String fileName, String& contentDispositionFileName)
at Microsoft.Web.PlatformInstaller.InstallManager.WinInetDownloadInstallerFile(InstallerContext currentInstall, String& failureReason)
DownloadManager Warning: 0 : WinInet failure: Url ‘http://download.moodle.org/download.php/direct/windows_wpi/MoodleWindowsWpi-latest-19-20101124.zip’ returned HTTP status code: 404. Retrying download for ‘Moodle’
DownloadManager Information: 0 : WebClient downloading file ‘http://download.moodle.org/download.php/direct/windows_wpi/MoodleWindowsWpi-latest-19-20101124.zip’ to: C:UsersrrruedAppDataLocalTemp2tmp4643.tmp
DownloadManager Information: 0 : Install exit code for product ‘Windows Cache Extension 1.1 for PHP 5.2’ is 0
DownloadManager Information: 0 : Ignoring exit code 0 for product ‘Windows Cache Extension 1.1 for PHP 5.2’
DownloadManager Error: 0 : WebClient error while downloading file ‘http://download.moodle.org/download.php/direct/windows_wpi/MoodleWindowsWpi-latest-19-20101124.zip’. Exception: System.Net.WebException:
The remote server returned an error: (404) Not Found.
at System.Net.WebClient.OpenRead(Uri address)
at Microsoft.Web.PlatformInstaller.InstallManager.WebClientDownloadInstallerFile(InstallerContext currentInstall, String& errorMessage)
DownloadManager Warning: 0 : WebClient failure: The remote server returned an error: (404) Not Found.. Retrying download for ‘Moodle’
DownloadManager Information: 0 : Downloading file ‘http://download.moodle.org/download.php/direct/windows_wpi/MoodleWindowsWpi-latest-19-20101124.zip’ to: C:UsersrrruedAppDataLocalTemp2tmp5150.tmp
DownloadManager Information: 0 :
http://download.moodle.org/download.php/direct/windows_wpi/MoodleWindowsWpi-latest-19-20101124.zip
responded with 404
DownloadManager Information: 0 : Response headers:
HTTP/1.1 404 Not Found
Date: Fri, 13 May 2011 15:09:40 GMT
Server: Apache/2.2.3 (CentOS)
X-Powered-By: PHP/5.1.6
Expires:
Cache-Control: private, pre-check=0, post-check=0, max-age=0
Pragma: no-cache
Content-Script-Type: text/javascript
Content-Style-Type: text/css
Content-Language: en
Accept-Ranges: none
Connection: close
Transfer-Encoding: chunked
Content-Type: text/html; charset=utf-8DownloadManager Error: 0 : Error while downloading file ‘http://download.moodle.org/download.php/direct/windows_wpi/MoodleWindowsWpi-latest-19-20101124.zip’. Exception: System.InvalidOperationException: Url
‘http://download.moodle.org/download.php/direct/windows_wpi/MoodleWindowsWpi-latest-19-20101124.zip’ returned HTTP status code: 404
at Microsoft.Web.PlatformInstaller.ManagedWinInet.OpenUrlAndFollowRedirects(Uri& uri, IntPtr& hInetFile)
at Microsoft.Web.PlatformInstaller.ManagedWinInet.DownloadFile(Uri uri, String fileName, String& contentDispositionFileName)
at Microsoft.Web.PlatformInstaller.InstallManager.WinInetDownloadInstallerFile(InstallerContext currentInstall, String& failureReason)
DownloadManager Error: 0 : WinInet failure: Url ‘http://download.moodle.org/download.php/direct/windows_wpi/MoodleWindowsWpi-latest-19-20101124.zip’ returned HTTP status code: 404. Download failure for Moodle.
Answers
-
User-162856161 posted
I fixed this today — you should be successful in installing Moodle now
Thanks
Chris
-
Marked as answer by
Tuesday, September 28, 2021 12:00 AM
-
Marked as answer by
The following solution works regardless of whether Moodle is installed in the webroot or in a sub-folder.
Replace the following lines:
@import url("../blocks/configurable_reports/js/datatables/media/css/jquery.dataTables.css");
@import url("../blocks/configurable_reports/js/codemirror/lib/codemirror.css");
@import url("../blocks/configurable_reports/js/codemirror/addon/display/fullscreen.css");
With this:
@import url("../../../../blocks/configurable_reports/js/datatables/media/css/jquery.dataTables.css");
@import url("../../../../blocks/configurable_reports/js/codemirror/lib/codemirror.css");
@import url("../../../../blocks/configurable_reports/js/codemirror/addon/display/fullscreen.css");
I tested this with Configurable Reports 3.1.1 (2016020103) on Moodle 3.4 using Chrome, Firefox, Edge and Internet Explorer.
Let me know if it doesn’t work for you.
Best regards,
Michael Milette
We have enabled some additional debugging and captured some relevant stack traces:
During the request, it first triggers this warning:
PHP Notice: Error: mdb->get_record() found more than one record!
line 1683 of /lib/dml/moodle_database.php: call to debugging()
line 1643 of /lib/dml/moodle_database.php: call to moodle_database->get_record_sql()
line 1622 of /lib/dml/moodle_database.php: call to moodle_database->get_record_select()
line 154 of /auth/oidc/classes/loginflow/authcode.php: call to moodle_database->get_record()
line 195 of /auth/oidc/auth.php: call to auth_oidc\loginflow\authcode->user_login()
line 4387 of /lib/moodlelib.php: call to auth_plugin_oidc->user_login()
line 510 of /auth/oidc/classes/loginflow/authcode.php: call to authenticate_user_login()
line 276 of /auth/oidc/classes/loginflow/authcode.php: call to auth_oidc\loginflow\authcode->handlelogin()
line 114 of /auth/oidc/classes/loginflow/authcode.php: call to auth_oidc\loginflow\authcode->handleauthresponse()
line 165 of /auth/oidc/auth.php: call to auth_oidc\ in /var/www/html/lib/weblib.php on line 3257
Then eventually throws with:
Default exception handler: There was a problem logging you in. Please contact your administrator for assistance. Debug: 2
Error code: errorauthgeneral
* line 528 of /auth/oidc/classes/loginflow/authcode.php: moodle_exception thrown
* line 276 of /auth/oidc/classes/loginflow/authcode.php: call to auth_oidc\loginflow\authcode->handlelogin()
* line 114 of /auth/oidc/classes/loginflow/authcode.php: call to auth_oidc\loginflow\authcode->handleauthresponse()
* line 165 of /auth/oidc/auth.php: call to auth_oidc\loginflow\authcode->handleredirect()
* line 29 of /auth/oidc/index.php: call to auth_plugin_oidc->handleredirect()n, referer: https://login.microsoftonline.com/
So it seems the final exception ultimately comes from here, suggesting that the call to moodle’s authenticate_user_login is failing for whatever reason.
The first error that we see, about there being more than one record, seems to come from here, which is a query to the same table that you just mentioned. However, when I query the table, there is only one record. This may be because this section of code tries to delete the token, but does it based on the token ID rather than the username, so it’d only be clearing the first token that was returned up in the call to $DB->get_record in user_login. That’d suggest a new token is being created on every request, and I’m not sure what that token looks like, but perhaps it has some sort of issue?
Does that help at all? Should we delete the existing token in the table? Is my understanding correct that there is a new token being inserted on each request (I guess from here, meaning the oidcuniqid is not matching the one in the table) that is invalid, and then removed?
- Forums
- Technical
- Virtual Learning Platforms
- Moodle 404 ALL THE TIME
- Data loading…
Virtual Learning Platforms Thread, Moodle 404 ALL THE TIME in Technical; Hey,
I recently set up Moodle for our school and I had problems during the inital web page set up- …
-
18th November 2014, 09:00 AM #1
Hey,
I recently set up Moodle for our school and I had problems during the inital web page set up- I was getting a LOT of 404 error. I managed to configure it after countless server reboots.. Now that moodle is configured.. but it’s 404 -.- I have never done moodle and I am a begginer on linux (I am using ubuntu 14.0.4.1 no gui). The file configuration is fine because it let me create everything. Why am I getting 404 so often? I know what 404 is not found but… I am lost. Halp..
Thanks
Edit: After server reboot, it works for a minute then 404’s.
-
18th November 2014, 09:33 AM #2
you need check your dns and IP config to start with
then you need to start looking in the error logs and seeing what’s happening. This depends on how your apache is set and if you have vhosts but to start with ‘tail -f /var/log/apache2/error.log’ should start to point you in the right direction.
-
18th November 2014, 10:08 AM #3
Make sure your Config.PHP is set up correctly and also any apache configs are correct.
Potentially your Config.PHP could be pointing to a directory that doesnt exist.
Can you access direct from the IP address instead of the DNS name?
-
18th November 2014, 10:40 AM #4
I am accessing it from the IP address- it works for a while then stops… So it has to be pointing correctly otherwise it would just 404 right away. Btw- I am using hyperv for the server.
This is my config php file: php.jpg
Last edited 18th November 2014 at 10:43 AM.
-
18th November 2014, 10:57 AM #5
Try and rewrite the wwwroot URL it looks like part of it is being contained in the string and some of it isnt
Moodle.png
See how mine is completely red? part of your wwwroot URL is white as if its just text and part of it is blue
It should all be blue.
Give this a try
-
18th November 2014, 11:12 AM #6
Originally Posted by Dkeen94
Try and rewrite the wwwroot URL it looks like part of it is being contained in the string and some of it isnt
Moodle.png
See how mine is completely red? part of your wwwroot URL is white as if its just text and part of it is blue
It should all be blue.
Give this a try
It is correct- the nano editor just shows up wrong- I used vim here to show you that is is correct format.
php2.jpg
-
18th November 2014, 12:26 PM #7
Managed to fix it- I had a clash of static IP addresses. Works like a charm now
SHARE:
Similar Threads
-
Replies: 5
Last Post: 30th April 2012, 02:10 PM
-
Replies: 5
Last Post: 26th January 2009, 01:50 PM
-
Replies: 13
Last Post: 19th July 2008, 09:09 AM
-
Replies: 6
Last Post: 9th May 2008, 03:53 PM
-
Replies: 11
Last Post: 4th March 2008, 10:29 PM
- Moodle 404 ALL THE TIME
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)


