Admin cannot login after migrating to new server

Admin cannot login after migrating to new server

by T K -
Number of replies: 8

I am using Moodle 3.5 and earlier today we had just migrated our Moodle from IP A to IP B in a new server.

Our DNS pointing is setup, I have done search & replace of the DB. 

My login page looks perfect but I cannot login! I changed the password on CLI & verified the user exists in DB.


Then out of curiosity I opened the config.php and enabled these lines (originally they are commented out):


@error_reporting(E_ALL | E_STRICT); // NOT FOR PRODUCTION SERVERS!

@ini_set('display_errors', '1');    // NOT FOR PRODUCTION SERVERS!

$CFG->debug = (E_ALL | E_STRICT);   // === DEBUG_DEVELOPER - NOT FOR PRODUCTION SERVERS!

$CFG->debugdisplay = 1;             // NOT FOR PRODUCTION SERVERS!


To my surprise I am able to login now!

What is the issue here and how can I fix this? Every time I comment these lines I lose login access to my Moodle site!

I have another working Moodle site, and through the browser developer tools I see that every time login, there is a token generated in the back-end. 

However through this login (debug enabled), there is not token generated.


Please someone help!!

Average of ratings: -
In reply to T K

Re: Admin cannot login after migrating to new server

by T K -
BTW despite having debug turned on, when i login, i dont see any error msges
And the sessions folder in my moodledata is empty.
In reply to T K

Re: Admin cannot login after migrating to new server

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
Are you sure that the new environment satisfies the https://docs.moodle.org/dev/Moodle_3.5_release_notes#Server_requirements ? Are the system software identical, I mean Apache vs. Nginx, MySQL vs. MariaDB, php-cgi vs. php-fpm, ..?

You checked the obvious, write permissions in the sessions directory, right?
Average of ratings: Useful (1)
In reply to Visvanath Ratnaweera

Re: Admin cannot login after migrating to new server

by T K -
Thanks for the reply Sir.

Yes I have these:
drwxr-xr-x. 17 apache apache 253 Jun 19 19:22 moodledataABS
[root@AICB-Moodle2001 moodledataABS]# php -v
PHP 7.0.33 (cli) (built: Oct 22 2019 10:24:41) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
with Zend OPcache v7.0.33, Copyright (c) 1999-2017, by Zend Technologies
[root@-Moodle2001 moodledataABS]# mysql -V
mysql Ver 14.14 Distrib 5.6.40, for Linux (x86_64) using EditLine wrapper
[root@-Moodle2001 moodledataABS]#
In reply to Visvanath Ratnaweera

Re: Admin cannot login after migrating to new server

by T K -

Now I can also see this error:


In reply to T K

Re: Admin cannot login after migrating to new server

by T K -

This is my sessions handling settings:



Since it is using DB for sessions, how do I clear the DB cache / sessions?

In reply to T K

Re: Admin cannot login after migrating to new server

by Ken Task -
Picture of Particularly helpful Moodlers

Uncheck.  Should be using files then.  Also check max_allowed_packet ... use mysql client on server:

show variables like 'max_allowed_packet;

The advice on notice says at least 4M.

If you set via my.cnf, restart mysqld for the changes to take affect.

'SoS', Ken

Average of ratings: Useful (1)
In reply to T K

Re: Admin cannot login after migrating to new server

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Is your login page just core Moodle code or is it something custom?

What theme are you using? If not a core theme, switch to Boost (to see if it makes any difference)
Average of ratings: Useful (1)
In reply to Howard Miller

Re: Admin cannot login after migrating to new server

by T K -
Thanks all for your replies.

We solved this problem by setting the /etc/hosts file with the IP number.