Error 504 when enrolling users

Error 504 when enrolling users

by Lebato MT -
Number of replies: 2

Good day

I am having challenges on my current live site. We recently deployed Moodle 4.5, it was a clean installation. Everything worked well at first, howver we started havijg challenges ith both manual and bulk enrolment of users.

the system returns error ' 504 Gatewat Time-out' when we bulk enrol using a csv file and when we manually enrol from the course level.

The error also shows up when users submit assignments via file submissions options.

System details:

Moodle version: 4.5.2

Webserver: Nginx

PHP version: 8.2. [settings past_max_size=100M,max_file_upload_size:100M,max_execusion_time=360,max_input_time=60,memory_limit=256]

Database engine : Mariadb

Average of ratings: -
In reply to Lebato MT

Error 504 when enrolling users

by Ken Task -
Picture of Particularly helpful Moodlers

From an AI Gemini Google

A 504 Gateway Timeout error means that the server, while acting as a gateway or proxy, didn't receive a timely response from an upstream server. Essentially, the server you're trying to reach is waiting for another server to respond, but that other server is taking too long or not responding at all. This is a common issue that can be caused by various factors, and while often temporary, it can be frustrating for users. 
Here's a breakdown of the error and how to address it:

What it means:

Server acting as a gateway or proxy:
This means the server you're connecting to (e.g., your web browser) is trying to access another server to get the content you requested. 

No response from upstream server:
The server you're trying to reach (the upstream server) didn't send back a response within the allotted time, causing a timeout. 
Temporary or persistent issue:
The error can be a temporary glitch due to high traffic or a more persistent problem with the upstream server. 


Causes:

Server overload: The upstream server might be experiencing high traffic, making it slow to respond. 

Slow server response: The upstream server might be slow due to inefficient code, slow database queries, or hardware limitations. 
Network issues: Problems with the network connection between the servers can also cause timeouts. 
Firewall or security software: Firewalls or security software might be blocking legitimate traffic. 
DNS issues: Incorrect DNS settings can also lead to 504 errors. 
Misconfigured server: Servers that are not properly configured can also cause timeouts


How to troubleshoot:

Refresh the page: A simple refresh can sometimes resolve temporary issues. 
Check server status: Verify that the upstream server is up and running. 
Check server logs: Examine server logs for clues about the cause of the timeout. 
Test with different networks: Try accessing the site from different networks (e.g., mobile data vs. Wi-Fi) to see if the issue is network-related. 
Check firewall settings: Ensure your firewall or security software isn't blocking the necessary traffic. 
Test with different browsers: Try a different web browser to rule out browser-specific issues. 
Clear browser cache and cookies: This can help resolve issues related to stored data. 
Flush DNS: Clearing your DNS cache can also help. 
Check website's plugins: On platforms like WordPress, plugins can sometimes cause 504 errors. 
Contact website administrator: If you suspect a problem with the website's server, contact the website administrator for assistance. 
Monitor for DDoS attacks: Aggressive bots and DDoS attacks can overwhelm servers. 
Adjust server configuration: Review your server configuration and make necessary adjustments. 
Check for large HTTP headers: Large HTTP headers can cause timeouts. 
Check your CDN: If you're using a CDN, check if there are any issues with it. 
Disable HTTP/2 to Origin (Cloudflare): If you're using Cloudflare, disabling HTTP/2 to Origin might help. 

Sent you a PM with some questions ... please respond there!

'SoS', Ken

In reply to Ken Task

Error 504 when enrolling users

by Lebato MT -
Thank you @Ken

Here are the troubleshooting steps we have already taken:

1. Server status: We checked both nginx and PHP status and they are running [systemctl status nginx, systemctl status php8.2-fpm]
2. After checking the error.log in the /var/log/nginx directory:
"line 582 of /theme/degrade/lib.php: call to core\output\theme_config->setting_file_serve()
* line 5341 of /lib/filelib.php: call to theme_degrade_pluginfile()
* line 44 of /pluginfile.php: call to file_pluginfile()" while reading response header from upstream, client: 10.20.163.238, server: taxacademy.ataftax.org, request: "GET /pluginfile.php/1/theme_degrade/logo_write/1751499283 HTTP/1.1", upstream: "fastcgi://unix:/run/php/php8.2-fpm.sock:", host: "taxacademy.ataftax.org", referrer: "https://taxacademy.ataftax.org/admin/search.php"
2025/07/03 08:05:34 [error] 3840#3840: *2668 FastCGI sent in stderr: "PHP message: Default exception handler: Sorry, the requested file could not be found Debug:
Error code: filenotfound
* line 2148 of /lib/filelib.php: core\exception\moodle_exception thrown
* line 1827 of /lib/classes/output/theme_config.php: call to send_file_not_found()
* line 582 of /theme/degrade/lib.php: call to core\output\theme_config->setting_file_serve()
* line 5341 of /lib/filelib.php: call to theme_degrade_pluginfile()
* line 44 of /pluginfile.php: call to file_pluginfile()" while reading response header from upstream, client: 10.20.163.238, server: taxacademy.ataftax.org, request: "GET /pluginfile.php/1/theme_degrade/logo_write/1751499283 HTTP/1.1", upstream: "fastcgi://unix:/run/php/php8.2-fpm.sock:""
Seeing that the error is related to the theme in use, we then chnaged the theme back to Boost and ran the tests again. The error 504 still persisted unfortunately.

3. We tested the issue with multiple networks, including enabaling and disabling VPN. The issue affects all the users in the system
4. We have not blocked traffic on the internal firewall and WAF yet
5. We tested with different browsers and the error still persist
6. We cleared browser cache and purched cache on Moodle multiple times
7. We flushed DNS cache
8. We have some few additional plugins but most of them are not in use yet, as the site is still very new. the nginx logs shows theme related errors only, but the error still persist even with Bosst theme activated
9.We have made some few optimization on nginx configuration file and php.ini file. we checked settings suc as:
client_max_body_size 100M;
fastcgi_buffers 16 16k;
fastcgi_buffer_size 32k;
fastcgi_read_timeout 60;
10. We use WAF to minitor attacks

I hope the above have provided some clarity on how the system is currently setup