404 Error on Manager page

I’m trying to login to my manager page (was logged in last week without issues), but now I’m forwarded to my sites 404 error page after entering my login credentials.

The site seems to be working fine otherwise. I’m not sure exactly what version I’m on, because I cannot login, but it’s revolution 2.???

Any suggestions of where to start to correct this issue? Any help would be greatly appreciated. Thanks!

UPDATE
Found some info in the /core/cache/logs/error.log

I have a bunch of errors containing “core/components/formit/src/FormIt/Hook/Email.php : 322) [FormIt] An error occurred while trying to send the email. Could not instantiate mail function.”, but I just checked it, and FormIt is still working to send emails via our contact form.

After a bunch of those errors from the last few months, I also have this error below, which seems to be the source of my issue. Does anyone have any suggestions?

core/xpdo/om/xpdoobject.class.php : 1452) Error 23000 executing statement:
I
INSERT INTO `modx_session` (`id`, `access`, `data`) VALUES ('97bloa53umb6co9ih53l3d11c5', 1677011716, 'modx.user.contextTokens|a:0:{}modx.user.0.resourceGroups|a:1:{s:3:\"mgr\";a:0:{}}modx.user.0.attributes|a:1:{s:3:\"mgr\";a:5:{s:16:\"modAccessContext\";a:1:{s:3:\"web\";a:1:{i:0;a:3:{s:9:\"principal\";i:0;s:9:\"authority\";s:1:\"0\";s:6:\"policy\";a:3:{s:4:\"load\";b:1;s:6:\"formit\";b:1;s:18:\"formit_encryptions\";b:0;}}}}s:22:\"modAccessResourceGroup\";a:0:{}s:17:\"modAccessCategory\";a:0:{}s:28:\"sources.modAccessMediaSource\";a:0:{}s:18:\"modAccessNamespace\";a:0:{}}}')
A
Array
(
(
 
    [0] => 23000
 
    [1] => 1062
 
    [2] => Duplicate entry '97bloa53umb6co9ih53l3d11c5' for key 'PRIMARY'
)
)

Check the modx_session table in PhpMyAdmin. If may be corrupted or full. You can repair it in PhpMyAdmin, but if it’s huge, you could also just empty it (but don’t delete the table itself). That might let you log in.

The mail thing makes me wonder. I don’t know how likely it is, but possibly someone (probably a bot) is trying to hijack your contact form to send their own emails.

What version of MODX are you running? If you’re not sure, you can check the core/docs/version.inc.php file.

Thanks for the reply, bobray. This table wasn’t very large (2MB). I tried to repair it, but still got the same error.

I tried emptying the table, but the result is the same. I’m checking to see if the login works by using Incognito mode, so it shouldn’t be a browser cache issue.

We’re on version 2.6.5. I certainly need to upgrade once I resolve this current issue.

Would adding recaptcha to formit help to mitigate the possible hijacking issue?

Thanks again!

Most hackers can now break through reCaptcha. The Akismet extra from modmore is very effective. It’s easy to use and informative. The extra is free, but there’s a modest, self-selected fee for the Akismet account. It solved a problem with some persistent registration hackers at Bob’s Guides.

1 Like

Thanks for the formit insight - I’ll have to check out your suggestion.

Any other thoughts regarding the manager 404?

Is it still the same error? Duplicate entry '...' for key 'PRIMARY'?
Did you delete the whole content of the table modx_session (TRUNCATE TABLE modx_session)?
Did you delete the cookies in your browser?


You could also try changing the system setting session_handler_class.

In the database table modx_system_settings, set the value of the row with the key = session_handler_class to an empty string. Then session shouldn’t be stored in the database anymore and the standard PHP session management will be used.

Also make sure to delete the cache folder (core/cache) after the change.

No additional errors mentioning the duplicate entry have appeared in the error log since my initial issue, regardless of how many times I’ve tried logging in since.
I did delete the modx_session contents (went from ~2MB to 0kb), to no avail.
I did not delete the cookies in my browser, as I’m working in fresh incognito windows for each new attempt. I have also attempted to login from another computer that I had not used for the site in question previously.

Before trying the second portion of your response as a potential fix, I did see some new errors this morning when checking my error log. Please see below. Thank you!

[2023-02-22 16:15:36] (ERROR in xPDOConnection::connect @ /core/xpdo/xpdo.class.php : 3119) SQLSTATE[HY000] [2002] Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
[2023-02-22 16:15:36] (ERROR @ /core/xpdo/om/xpdoquery.class.php : 652) Could not construct or prepare query because it is invalid or could not connect: SELECT `modExtensionPackage`.`id`, `modExtensionPackage`.`namespace`, `modExtensionPackage`.`name`, `modExtensionPackage`.`path`, `modExtensionPackage`.`table_prefix`, `modExtensionPackage`.`service_class`, `modExtensionPackage`.`service_name`, `modExtensionPackage`.`created_at`, `modExtensionPackage`.`updated_at`, Namespace.path AS namespace_path FROM `modx_extension_packages` AS `modExtensionPackage` JOIN `modx_namespaces` `Namespace` ON `modExtensionPackage`.`namespace` =  `Namespace`.`name` ORDER BY namespace ASC 
[2023-02-22 16:15:36] (ERROR in xPDOConnection::connect @ /core/xpdo/xpdo.class.php : 3119) SQLSTATE[HY000] [2002] Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
[2023-02-22 16:15:36] (ERROR @ /core/xpdo/om/xpdoquery.class.php : 652) Could not construct or prepare query because it is invalid or could not connect: SELECT `modSession`.`id` AS `modSession_id`, `modSession`.`access` AS `modSession_access`, `modSession`.`data` AS `modSession_data` FROM `modx_session` AS `modSession` WHERE `modSession`.`id` = ? 
[2023-02-22 16:15:36] (ERROR in xPDOConnection::connect @ /core/xpdo/xpdo.class.php : 3119) SQLSTATE[HY000] [2002] Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
[2023-02-22 16:15:36] (ERROR @ /core/xpdo/om/xpdoobject.class.php : 263) Error preparing statement for query: SELECT `modSession`.`id` AS `modSession_id`, `modSession`.`access` AS `modSession_access`, `modSession`.`data` AS `modSession_data` FROM `modx_session` AS `modSession` WHERE `modSession`.`id` = ?  - 
[2023-02-22 16:15:37] (ERROR in xPDOConnection::connect @ /core/xpdo/xpdo.class.php : 3119) SQLSTATE[HY000] [2002] Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
[2023-02-22 16:15:37] (ERROR @ /core/xpdo/om/xpdoquery.class.php : 652) Could not construct or prepare query because it is invalid or could not connect: SELECT `seoKeywords`.`id` AS `seoKeywords_id`, `seoKeywords`.`resource` AS `seoKeywords_resource`, `seoKeywords`.`keywords` AS `seoKeywords_keywords` FROM `modx_seopro_keywords` AS `seoKeywords` WHERE `seoKeywords`.`resource` = ? 
[2023-02-22 16:15:37] (ERROR in xPDOConnection::connect @ /core/xpdo/xpdo.class.php : 3119) SQLSTATE[HY000] [2002] Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
[2023-02-22 16:15:37] (ERROR @ /core/xpdo/om/xpdoobject.class.php : 263) Error preparing statement for query: SELECT `seoKeywords`.`id` AS `seoKeywords_id`, `seoKeywords`.`resource` AS `seoKeywords_resource`, `seoKeywords`.`keywords` AS `seoKeywords_keywords` FROM `modx_seopro_keywords` AS `seoKeywords` WHERE `seoKeywords`.`resource` = ?  - 
[2023-02-22 16:15:37] (ERROR in xPDOConnection::connect @ /core/xpdo/xpdo.class.php : 3119) SQLSTATE[HY000] [2002] Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
[2023-02-22 16:15:37] (ERROR @ /core/xpdo/om/xpdoquery.class.php : 652) Could not construct or prepare query because it is invalid or could not connect: SELECT `modSession`.`id` AS `modSession_id`, `modSession`.`access` AS `modSession_access`, `modSession`.`data` AS `modSession_data` FROM `modx_session` AS `modSession` WHERE `modSession`.`id` = ? 
[2023-02-22 16:15:37] (ERROR in xPDOConnection::connect @ /core/xpdo/xpdo.class.php : 3119) SQLSTATE[HY000] [2002] Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
[2023-02-22 16:15:37] (ERROR @ /core/xpdo/om/xpdoobject.class.php : 263) Error preparing statement for query: SELECT `modSession`.`id` AS `modSession_id`, `modSession`.`access` AS `modSession_access`, `modSession`.`data` AS `modSession_data` FROM `modx_session` AS `modSession` WHERE `modSession`.`id` = ?  - 
[2023-02-22 16:15:37] (ERROR in xPDOConnection::connect @ /core/xpdo/xpdo.class.php : 3119) SQLSTATE[HY000] [2002] Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
[2023-02-22 16:15:37] (ERROR in xPDOConnection::connect @ /core/xpdo/xpdo.class.php : 3119) SQLSTATE[HY000] [2002] Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)

I’m thinking it’s a problem with a plugin (or your DB is overloaded).

Do you have an SEO-related plugin?

If so, try disabling it in the modx_site_plugins table. Consider disabling all your plugins. if that works, re-enable them one by one. Clearing the cache after each one and seeing if you can log in. That should find the culprit.

Okay, thanks for the insight. modx_site_plugins is only 96KiB, and I only have SEOPro and FormIt. I’ve changed the “disabled” option on both from 0 to 1, cleared the cache folder, and still the same issue is occurring.

I’ve sorted the database by size, and the largest table is modx_transport_packages at only 1.6MiB. FormIt is showing 13K rows, which includes a substantial number of spam messages.

Per halftrainedharry’s suggestion, I changed the session_handler_class from “modSessionHandler” to an empty string, then emptied the cache folder. I’m still getting the same 404 on my site after attempting to login.

I also thought it worth mentioning, that prior to clearing the cache, I did not have any additional errors in the error log.

Thanks again for sticking with me on this issue.

Try turning on Dev. tools (ctrl-shift-i), and watch the Network tag as you try to log in. You may catch a look at the page it’s trying to load. You can also “drill down” on each entry in the grid by clicking on it. If it then shows a response tab check it and see if there’s an error message there. It will be buried in some complex HTML, but you can usually see an error message there somewhere.

Another thought. Is your Login snippet tag using any properties like &loginResourceId, &redirectToPrior, &preHooks, or &postHooks?

You can see the tag in the modx_site_content record for the Login resource. If any of those are there, try removing them. Then manually clear the cache before logging in.

Also, the next time you end up at the 404 page try entering something like this in the browser’s address bar:

http://yoursite.com/manager/?a=resource/update&id=1

Just because you’re on the 404 page, doesn’t necessarily mean you’re not logged in. If you’re logged in, the command above should let you edit the home page (Assuming that its ID is 1).

When checking with dev tools, the first “name” is “manager/” (showing status code 302), then “manager” (without the /, showing status code 301), then the third line with “manager/” is in red showing status code 404. I quickly scanned the 43 requests, and nothing sticks out in the “Response” tab. In the 3rd “manager/” result, the only instance of the word “error” was just in the expected HTML of my coded 404 page. There is a fourth instance of “manager/” in red closer to the end of the list of requests, but the “Response” page says Failed to load response data: No data found for resource with given identifier.

I don’t have any Login resource under modx_site_content - I don’t believe I’ve made any changes to the default manager login, if memory serves. Is this Login resource missing, or would it not be included if no modifications had been made?

On a positive note, using the modification to the web address /?a=resource/update&id=1 allowed me to get into the manager to modify the page with ID 1. I was also able to click on other links inside of the manager, except for when trying to access the manager homepage using the Modx logo link in the upper left-hand corner. Hopefully, this detail points to a subsequent step to discovering the cause of this issue.

I doubt this is relevant, but I haven’t modified anything major on the site since initially putting it online in 2018. I’ve been browsing the files via FTP, just to see if there was anything strange regarding modification dates, but everything appears as expected (with most of the Modx backend files having the original upload date on them). I guess that just points back to some sort of database issue/error.

Does it work when you call http://yoursite.com/manager/index.php?a=welcome

This does not work - it sends me to the 404 page.

So http://yoursite.com/manager/index.php?a=resource/update&id=1 works, but
http://yoursite.com/manager/index.php?a=welcome doesn’t?
That’s weird.


Are there any plugins that run on the events OnMODXInit, OnHandleRequest, OnManagerPageInit (or similar) that may try to redirect a request?

There is a list of events in the tab “System Events” on the page /manager/?a=system/settings that shows which plugins run on which events.


You could also try deleting the rows in the table modx_dashboard_widget_placement. These are the widgets that get displayed on the welcome page. This probably doesn’t help, but maybe one of the widgets causes a problem.

1 Like

That’s correct - doesn’t make much sense to me either.

OnMODXInit - seoPro (I had previously disabled this plugin in the database, per bobray’s suggestion, to no avail)
OnHandleRequest - none
OnManagerPageInit - none

I deleted widget 5, which was at the top of the list in modx_dashboard_widget_placement, and that seems to have returned things to normal!

Based on modx_dashboard_widget (assuming the ID numbers transfer from modx_dashboard_widget to modx_dashboard_widget_placement), this appears to have been an issue with (5, 'w_configcheck', 'w_configcheck_desc', 'file', '[[++manager_path]]controllers/default/dashboard/widget.configcheck.php', 'core', 'core:dashboards', 'full'),

Any thoughts as to why that may have been where the problem was?

I don’t know. The values in the database table look correct.
Maybe the PHP version on your hosting was updated, and as your MODX version is quite old, this widget possibly wasn’t compatible anymore.

I would upgrade to the current version of MODX 2.x and then try again, if the widget still causes problems.


Do you always get a 404 error (and not a 500) when there is a problem with the code? That’s quite misleading when trying to figure out what happens.

So strange. That very well could be it.

I have the “Upgrade MODX” plugin installed, but since I have been unable to get the “BackupMODX” plugin to work properly, I’ve been reluctant to use the upgrade plugin. Do you have a preferred upgrade path that you could recommend?

I also noticed that the package provider “https://rest.modx.com/extras/” is no longer valid, so I’m not able to check for current updates to these existing addons.

This problem (or really any problem) with this site has not occurred before last week, and the 404 page error (set by system setting error_page) is the only page error I’ve received since this problem began.

Thanks again for all of you help on this!

These are two completely different extras by two different authors.

You could always do a manual upgrade

https://docs.modx.com/current/en/getting-started/maintenance/upgrading

But I would probably make a backup and then try “Upgrade MODX”.

This URL should still be valid.

I understand, it just had me a bit hesitant to trust an extra to run my upgrade via the Upgrade plugin when the BackupMODX plugin I was using to make a backup prior to upgrading wouldn’t work properly.

Thanks for the suggestion.

That URL is returning {"status":404,"message":"Resource not found"} when I try it, so I thought that URL may have been replaced by something else in newer versions.

This just happened on one of our sites. By using the direct url to any non-dashboard pages, I was able to get into the manager and remove the config check widget and the welcome page / dashboard reappeared. That’s progress.

However, the Package management page doesn’t show any installed extras. “No Data to Display”. Immediately after the page loads, it jumps a little, once, then looks fine. None of the menu items or buttons on the right side of the page work at all. When I hover over them I get a four-sided arrow icon. If I refresh the page, the top third of the page scrolls up and out of the browser window with no scroll bar. The left side resource list links work just fine.

There are no errors in the Modx log while accessing or refreshing this page. I can see all the system settings for all the installed extras.

Any thoughts?