Moodle 503 service temporarily unavailable

NethServer Version: NS7.4
Module: moodle 3.4

I had moodle 3.4 running fine. But this morning I tried to load the webinterface and I get:

Service Unavailable
The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.

It throws a 503 service temporaily unavailable. I browsed through the logs but could find any relevant snippets…
any ideas to troubleshoot this?

You may

  • check if database is running/accessible
  • check if php service is running and uses same port as defined in /etc/httpd/conf.d/moodle.conf

I see the same error message in sogo when the sogo service is not running.

php service (php71) is running.
Are you sure about the location for moodle.conf?
I get:

[root@ns7 /]# cat /etc/httpd/moodle.conf
cat: /etc/httpd/moodle.conf: No such file or directory

Or is this the source of the problem?

/edit: Found the location. It is /etc/httpd/conf.d/moodle.conf
and the port was set to 9000 instead of 9001 for php71 (how come this suddenly changed? update of php modules?)

1 Like

I did the moodle howto/package in between of Nextcloud 12 to 13 upgrade where php changed from 5.6 to 7.1. It seems also the port changed from 9000 to 9001 to be able to have php56 and php71 in parallel. I’ll correct that asap.
Maybe we could use a db prop for the port or let moodle search for php…

Just had an update on my server again and the port for php71 was again at 9000. Manually set it to 9001 again and restarted httpd service. Now Moodle is available again.
Can you guide me to create a more permanent solution to this? I guess a custom template is needed, but I still have no clue how to do this…

Sorry for the delay…

I updated the package to use port 9001 (please be sure to have a backup of the moodle db to be safe) :

mrmarkuzrepo is down due to DNS issues, so here’s another link:

yum install

Another way would be to edit /etc/e-smith/templates/etc/httpd/conf.d/moodle.conf/10base or create a custom template out of it but I’d recommend the package.

I opted for your last solution: changed the template that already exists.
Very easy:
SSH into the server
if you ssh as root edit the file with your favorite text editor (mine is nano)
nano /etc/e-smith/templates/etc/httpd/conf.d/moodle.conf/10base

Alias /moodle /usr/share/moodle
<Directory /usr/share/moodle>
Require all granted
<FilesMatch .php$>
SetHandler “proxy:fcgi://”
< /FilesMatch>
< /Directory>

Change the port from 9000 to 9001: SetHandler “proxy:fcgi://” becomes SetHandler "proxy:fcgi://"
Save your changes by pressing ctrl - o
exit nano by pressing ctrl - x


in your template do

<FilesMatch .php$>
SetHandler “proxy:fcgi://{${'rh-php71-php-fpm'}{'TCPPorts'} || '9001'}
< /FilesMatch>

you should retrieve directly the tcp port, of course even if the service port is updated, you might need to expand again the template

1 Like

Care to explain this part to a non coder?

I think it is to only set listening port for phpfpm71 on port 9001, but don’t know what does what exactly…

{} in a template starts to code in perl

${‘rh-php71-php-fpm’}{‘TCPPorts’} retrieve the value of the e-smith database key

 [root@test ~]# config show rh-php71-php-fpm 

|| '9001'

secure your code by adding 9001 if you cannot retrieve the prop

in short even if the value change, if you expand your template, then you will have always the good tcp port

I must say I did not test my code, please do it :slight_smile:

1 Like

just did it, yes it works

1 Like

A month ago or so, Moodle 3.5 has been released. It shouldn’t be a reason to hurry and update, but this new version has some extra features that seem rather important, especially in Europe: focus is on extra GDPR compliance. See the new features and release notes for more info.

Can we do a combined effort to update the nethserver-moodle package to support moodle 3.5?

1 Like

I though, let’s give it a go to install Moodle on a fresh NS75 server.
So I updated the server to latest patchlevel.
Installed mrmarkuz repository
and did a yum install nethserver-moodle
All seems to get installed properly but I am (again) hitting a php version problem.
php71 packages are installed during moodle install, but when I check the php version on the serve rI receive back:

root@ns75 ~]# php -v
PHP 5.4.16 (cli) (built: Apr 12 2018 19:02:01)
Copyright © 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright © 1998-2013 Zend Technologies

And when I try to start moodle on https://NS75/moodle I get an error 503 service unavailable.
What am I missing here?

Thanks @robb for pointing this out, I could reproduce it.

In my case nethserver-rh-php71-php-fpm was missing, I have to update the moodle package as this is a missing dependency.


yum install nethserver-rh-php71-php-fpm
systemctl restart httpd

it should work.

The module still installs moodle 3.4. I used the 3.4 branch in the moodle package, I’ll update it asap.

Moodle uses php71-fpm so a php71 command line interface is not needed.


I updated the module to moodle 3.5 with working php71-fpm deps:

yum install

1 Like

I still have trouble getting moodle to work.

[root@ns75 ~]# ps aux | grep php-fpm
root 4475 0.0 1.7 507888 33168 ? Ss 19:35 0:00 php-fpm: master process (/etc/opt/rh/rh-php71/php-fpm.conf)
apache 4476 0.0 1.3 512752 25792 ? S 19:35 0:00 php-fpm: pool www
apache 4477 0.0 0.7 510536 14776 ? S 19:35 0:00 php-fpm: pool www
apache 4478 0.0 0.9 510520 17672 ? S 19:35 0:00 php-fpm: pool www
apache 4479 0.0 0.4 509972 8124 ? S 19:35 0:00 php-fpm: pool www
apache 4480 0.0 0.4 509972 8128 ? S 19:35 0:00 php-fpm: pool www
root 8933 0.0 0.0 112704 972 pts/0 S+ 20:46 0:00 grep --color=auto php-fpm

Checking port:

netstat -an | grep :9001
tcp 0 0* LISTEN

What am I missing here?

Thanks for testing!

By default you go to https://yournethserver.yourdomain.tld/moodle via the app button and maybe the name cannot be resolved.

To change it to use an IP address (or a working hostname) instead:

config setprop moodle host
signal-event nethserver-moodle-update

Looks like this is the solution. Even though I have NO entries in DNS, when I go to https://serverIP/moodle it changes to https://server.localdomain.tld/moodle
After setting an IP address as target: config setprop moodle host IPADDRESS I reach the moodle instance at https://IPADDRESS/moodle

Moodle uses a wwwroot config param in /usr/share/moodle/config.php and if no “host” is set, the template defaults to SYSTEMNAME.DOMAINNAME. It’s easier for me to get as one may use more IPs but only one Systemname.

my $host = ${'moodle'}{'host'} || $SystemName . '.' . $DomainName;
$OUT .= "\$CFG->wwwroot   = 'https://$host/moodle';";

It’s documented in the wiki:


I see you updated the module to Moodle 3.5
Can you update that info in the wiki too?

Yes and I’ll merge the pages as I used moodle34 as pagename because moodle already existed. It makes more sense to have just moodle.