{"id":15224,"date":"2026-12-05T18:00:46","date_gmt":"2026-12-05T12:30:46","guid":{"rendered":"https:\/\/www.mconnectmedia.com\/blog\/?p=15224"},"modified":"2026-12-05T18:00:46","modified_gmt":"2026-12-05T12:30:46","slug":"magento-admin-login-alert","status":"publish","type":"post","link":"https:\/\/www.mconnectmedia.com\/blog\/magento-admin-login-alert\/","title":{"rendered":"Get a Magento Admin Login Alert When Someone Signs In From a New Device"},"content":{"rendered":"\n<p>Magento doesn&#8217;t send a Magento admin login alert of any kind. An admin can sign in from a new country at 3 a.m. and nobody hears about it. A bot can try passwords against your admin sign-in page all night, and the only sign is an account that gets locked for half an hour. Below we show what Magento records about admin logins, how to check it by hand, and a free module our team wrote that emails you when something looks off.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Why a Magento admin login alert matters<\/h2>\n\n\n\n<p>Plenty of admin break-ins need no exploit at all. They start with a working password: one reused from another site that leaked, one typed into a phishing page, or one saved on the laptop of a developer who left two years ago. With that password, the attacker signs in like anyone else. They can add a new admin user, change a payment setting, or paste a script into a CMS block or the design configuration.<\/p>\n\n\n\n<p>Two-factor authentication stops most of this, and Magento 2.4 includes it. It isn&#8217;t the whole answer. Some stores switch it off, and some share one 2FA device among several staff. A login alert tells you about the sign-in itself, whatever let it through.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What Magento already does<\/h2>\n\n\n\n<p>Magento has a lockout. Open <strong>Stores &gt; Configuration &gt; Advanced &gt; Admin &gt; Security<\/strong> and you&#8217;ll find <strong>Maximum Login Failures to Lockout Account<\/strong> (6 by default) and <strong>Lockout Time (minutes)<\/strong> (30 by default). Adobe describes these in <a href=\"https:\/\/experienceleague.adobe.com\/en\/docs\/commerce-admin\/systems\/security\/security-admin\" target=\"_blank\" rel=\"noopener\">Configure Admin security<\/a>. Locked accounts are listed under <strong>System &gt; Permissions &gt; Locked Users<\/strong>, where you can also release them early.<\/p>\n\n\n\n<p>That&#8217;s useful, but it&#8217;s silent. Nobody gets an email when an account is locked, and nobody gets one when the right password is used from somewhere new.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How to check admin logins by hand<\/h2>\n\n\n\n<p>Magento Open Source keeps a little login data in the database. These queries work on 2.4. If your install uses a table prefix, add it to the table names.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Last login and failure count per admin<\/h3>\n\n\n\n<p>The <code>admin_user<\/code> table holds the time of each admin&#8217;s last successful login, the total number of logins, and the current failure count:<\/p>\n\n\n\n<p><code>SELECT username, is_active, logdate, lognum, failures_num, first_failure, lock_expires FROM admin_user ORDER BY logdate DESC;<\/code><\/p>\n\n\n\n<p>Times are in UTC. Look for accounts nobody on your team recognises, active accounts for people who have left, a <code>logdate<\/code> on an account that should never be used, and a <code>failures_num<\/code> above zero. This tells you when, but not from where.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Recent admin sessions with IP addresses<\/h3>\n\n\n\n<p>The Magento_Security module writes each admin session to <code>admin_user_session<\/code>, with the IP address:<\/p>\n\n\n\n<p><code>SELECT u.username, s.ip, s.status, s.created_at, s.updated_at FROM admin_user_session s JOIN admin_user u ON u.user_id = s.user_id ORDER BY s.created_at DESC LIMIT 50;<\/code><\/p>\n\n\n\n<p>A status of 1 means the session is still signed in. The catch is that a daily cron job, <code>security_clean_admin_expired_sessions<\/code>, deletes sessions that haven&#8217;t been active for a day. So this table only shows roughly the last 24 hours. If you look a week after something happened, the rows are gone.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Failed attempts in the web server log<\/h3>\n\n\n\n<p>Failed logins aren&#8217;t stored with an IP address anywhere in the database. Your web server access log has them as POST requests to the admin path. Find the admin path under <code>backend<\/code> &gt; <code>frontName<\/code> in <code>app\/etc\/env.php<\/code>, then count requests per IP. On a typical nginx server, with <code>admin_abc123<\/code> as the path:<\/p>\n\n\n\n<p><code>grep \"POST \/admin_abc123\" \/var\/log\/nginx\/access.log | awk '{print $1}' | sort | uniq -c | sort -rn | head<\/code><\/p>\n\n\n\n<p>This counts every admin POST, including saves and grid actions, so a busy admin user shows up too. It also depends on how long your host keeps the logs. All three checks work, but you only run them when you already suspect something.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Our free module: Magento 2 Admin Login Alert<\/h2>\n\n\n\n<p>We wanted the store to tell us, instead of us having to ask it. So we wrote <a href=\"https:\/\/www.mconnectmedia.com\/magento-2-admin-login-alert.html\">Magento 2 Admin Login Alert<\/a>. It listens to the two events Magento fires during admin sign-in, one for success and one for failure, and does three things.<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><strong>It records every attempt<\/strong> in its own table, <code>mconnect_admin_login_log<\/code>: username, admin user ID for successful logins, IP address, browser string, result and time. The history stays for 90 days, not one.<\/li><li><strong>It emails you about new logins.<\/strong> When an admin signs in, the module looks for a successful login by that account from the same IP address with the same browser in the last 90 days. If there isn&#8217;t one, you get a &#8220;New admin login&#8221; email with the username, IP address, browser and time in your store time zone.<\/li><li><strong>It emails you about repeated failures.<\/strong> After each failed sign-in it counts the failures for that username and from that IP address in the last 15 minutes. When either reaches 5, you get one &#8220;Failed admin logins&#8221; email. It sends at most one per username and per IP address each hour, so a bot running all night doesn&#8217;t fill your inbox.<\/li><\/ul>\n\n\n\n<p>You can read the history under <strong>System &gt; Admin Login History<\/strong>, newest first, 50 rows per page, with a filter for successful or failed logins. A daily cron job deletes rows older than the retention you set.<\/p>\n\n\n\n<p>Right after install the table is empty, so every admin would look new. To avoid a burst of emails on day one, the module records each admin&#8217;s first login without sending anything. From the second login on, the normal rule applies.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Settings<\/h3>\n\n\n\n<p>Everything is under <strong>Stores &gt; Configuration &gt; M-Connect Media &gt; Admin Login Alert<\/strong>, at the default scope.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Setting<\/th><th>Default<\/th><\/tr><\/thead><tbody><tr><td>Enabled<\/td><td>Yes<\/td><\/tr><tr><td>Send Alerts To<\/td><td>Empty, which uses the General Contact email<\/td><\/tr><tr><td>Email Sender<\/td><td>General Contact<\/td><\/tr><tr><td>Remember Known Logins For (Days)<\/td><td>90<\/td><\/tr><tr><td>Failed Logins Threshold<\/td><td>5<\/td><\/tr><tr><td>Time Window (Minutes)<\/td><td>15<\/td><\/tr><tr><td>Keep History For (Days)<\/td><td>90<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>Each alert type has its own Enabled switch. With the main switch set to No, nothing is recorded and no email goes out. Keep the history at least as long as the known login days, or the module forgets known logins early and sends extra emails.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Install<\/h3>\n\n\n\n<p>From the Magento root:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><code>composer config repositories.magento2-admin-login-alert vcs https:\/\/github.com\/mcsventures\/magento2-admin-login-alert<\/code><\/li><li><code>composer require mconnect\/module-admin-login-alert:^1.0<\/code><\/li><li><code>bin\/magento module:enable Mconnect_AdminLoginAlert<\/code><\/li><li><code>bin\/magento setup:upgrade<\/code><\/li><li><code>bin\/magento setup:di:compile<\/code> (production mode only)<\/li><li><code>bin\/magento cache:flush<\/code><\/li><\/ul>\n\n\n\n<p>To test it, sign out and back in once so your login is recorded. Then sign in from another browser or network and the &#8220;New admin login&#8221; email arrives. Magento cron has to run for the cleanup, and Magento has to be able to send email for the alerts. Errors and sent emails are logged in <code>var\/log\/admin_login_alert.log<\/code>. A mail server that&#8217;s down never stops an admin from signing in. The full test steps are in the <a href=\"https:\/\/github.com\/mcsventures\/magento2-admin-login-alert\" target=\"_blank\" rel=\"noopener\">README on GitHub<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What it leaves to Magento<\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li>It doesn&#8217;t block anyone. Magento&#8217;s lockout still decides when an account is locked. Use the module next to <a href=\"https:\/\/experienceleague.adobe.com\/en\/docs\/commerce-admin\/systems\/security\/2fa\/security-two-factor-authentication\" target=\"_blank\" rel=\"noopener\">two-factor authentication<\/a>, a custom admin path and an IP allow list where you can.<\/li><li>It doesn&#8217;t record logins through the REST admin token endpoint, <code>\/V1\/integration\/admin\/token<\/code>, because Magento doesn&#8217;t fire the same events there.<\/li><li>A wrong CAPTCHA on the admin sign-in page counts as a failed login, because Magento reports it through the same event.<\/li><li>It compares the full browser string. A browser update changes that string, so you can get a &#8220;new login&#8221; email from a known computer after an update.<\/li><li>If the admin sits behind a proxy or CDN that Magento isn&#8217;t set up to trust, every login shows the proxy&#8217;s IP address. Set up the real client IP header first.<\/li><li>The once per hour limit on failure emails uses the Magento cache, so flushing the cache resets it.<\/li><li>It sends nothing to any outside server. Emails go only to the addresses you set.<\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">If the login wasn&#8217;t one of yours<\/h2>\n\n\n\n<p>If an alert shows a login nobody on your team made, treat it as a break-in. Change that admin&#8217;s password, look for admin users and integrations you don&#8217;t recognise, and check CMS blocks and the design configuration for scripts you didn&#8217;t add. Then work out how the password got out. Our post on <a href=\"https:\/\/www.mconnectmedia.com\/blog\/magento-sessionreaper-patch-lessons\/\">what happened to stores that patched SessionReaper late<\/a> shows how fast attacks spread once a way in is public, and the <a href=\"https:\/\/www.mconnectmedia.com\/blog\/magento-payment-transaction-failed-email\/\">fake payment transaction failed email<\/a> post covers the checks we run on a server after an attack. If you&#8217;re planning an upgrade at the same time, read <a href=\"https:\/\/www.mconnectmedia.com\/blog\/magento-2-4-9-upgrade-what-breaks\/\">what breaks in a Magento 2.4.9 upgrade<\/a> first.<\/p>\n\n\n\n<p>If you want alerts somewhere else, say a Slack channel, our <a href=\"https:\/\/www.mconnectmedia.com\/magento-module-development\">Magento module development<\/a> team can add that to the module for you.<\/p>\n\n\n\n<p><strong>Want us to check how your admin is protected, or clean up after a login you didn&#8217;t expect? Start with a <a href=\"https:\/\/www.mconnectmedia.com\/magento-security-audit\">Magento security audit<\/a>, or ask about our <a href=\"https:\/\/www.mconnectmedia.com\/magento-support-services\">Magento support plans<\/a>, which start at $599 a month. Starting prices in USD, final quote after a short call. <a href=\"https:\/\/www.mconnectmedia.com\/contact\">Contact us<\/a>.<\/strong><\/p>\n\n\n\n<p>The source code and issue tracker are on <a href=\"https:\/\/github.com\/mcsventures\/magento2-admin-login-alert\" target=\"_blank\" rel=\"noopener\">the module&#8217;s GitHub page<\/a>. The download and changelog are on the <a href=\"https:\/\/www.mconnectmedia.com\/magento-2-admin-login-alert.html\">Magento 2 Admin Login Alert product page<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Sources<\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li><a href=\"https:\/\/experienceleague.adobe.com\/en\/docs\/commerce-admin\/systems\/security\/security-admin\" target=\"_blank\" rel=\"noopener\">Adobe: Configure Admin security<\/a><\/li><li><a href=\"https:\/\/experienceleague.adobe.com\/en\/docs\/commerce-admin\/systems\/security\/2fa\/security-two-factor-authentication\" target=\"_blank\" rel=\"noopener\">Adobe: Two-factor authentication<\/a><\/li><li><a href=\"https:\/\/github.com\/mcsventures\/magento2-admin-login-alert\" target=\"_blank\" rel=\"noopener\">Magento 2 Admin Login Alert on GitHub<\/a><\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">More free extensions from our team<\/h2>\n\n\n<ul><!-- mcm-free-ext -->\n<li><a href=\"https:\/\/www.mconnectmedia.com\/magento-2-payflow-guard.html\">Magento 2 Payflow Guard<\/a> (free, <a href=\"https:\/\/github.com\/mcsventures\/magento2-payflow-guard\" target=\"_blank\" rel=\"noopener\">source on GitHub<\/a>)<\/li>\n<li><a href=\"https:\/\/www.mconnectmedia.com\/magento-2-store-health-check.html\">Magento 2 Store Health Check<\/a> (free, <a href=\"https:\/\/github.com\/mcsventures\/magento2-store-health-check\" target=\"_blank\" rel=\"noopener\">source on GitHub<\/a>)<\/li>\n<li><a href=\"https:\/\/www.mconnectmedia.com\/magento-2-spam-registration-blocker.html\">Magento 2 Spam Registration Blocker<\/a> (free, <a href=\"https:\/\/github.com\/mcsventures\/magento2-spam-registration-blocker\" target=\"_blank\" rel=\"noopener\">source on GitHub<\/a>)<\/li>\n<!-- \/mcm-free-ext --><\/ul>\n\n\n<p>Every free module we have released so far is on our <a href=\"https:\/\/www.mconnectmedia.com\/free-magento-2-extensions\">free Magento 2 extensions<\/a> page, each with its setup guide and Composer package. Our paid modules are in the <a href=\"https:\/\/www.mconnectmedia.com\/magento-2-extensions.html\">Magento 2 extensions<\/a> store.<\/p>\n\n","protected":false},"excerpt":{"rendered":"<p>Magento doesn&#8217;t send a Magento admin login alert of any kind. An admin can sign in from a new country at 3 a.m. and nobody<\/p>\n","protected":false},"author":1,"featured_media":15223,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"footnotes":""},"categories":[2601,2572],"tags":[2630,2626,138,722],"class_list":["post-15224","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-magento-extensions","category-magento-security","tag-admin","tag-extensions","tag-magento","tag-security"],"_links":{"self":[{"href":"https:\/\/www.mconnectmedia.com\/blog\/wp-json\/wp\/v2\/posts\/15224","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.mconnectmedia.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.mconnectmedia.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.mconnectmedia.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.mconnectmedia.com\/blog\/wp-json\/wp\/v2\/comments?post=15224"}],"version-history":[{"count":3,"href":"https:\/\/www.mconnectmedia.com\/blog\/wp-json\/wp\/v2\/posts\/15224\/revisions"}],"predecessor-version":[{"id":15343,"href":"https:\/\/www.mconnectmedia.com\/blog\/wp-json\/wp\/v2\/posts\/15224\/revisions\/15343"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.mconnectmedia.com\/blog\/wp-json\/wp\/v2\/media\/15223"}],"wp:attachment":[{"href":"https:\/\/www.mconnectmedia.com\/blog\/wp-json\/wp\/v2\/media?parent=15224"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.mconnectmedia.com\/blog\/wp-json\/wp\/v2\/categories?post=15224"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.mconnectmedia.com\/blog\/wp-json\/wp\/v2\/tags?post=15224"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}