If you’re seeing “too many logins” or “maximum number of logins exceeded” when trying to sign in to a Linux user account, it usually means the system has a limit on concurrent sessions or failed attempts. This guide walks you through identifying and fixing the cause, whether it’s a session limit, a PAM setting, or a stuck process.
What You’ll Need
- Root or sudo access to the Linux machine
- Access to a terminal (local console or SSH)
- Basic familiarity with command-line text editors (like nano or vim)
Step-by-Step
- Check if the user is currently logged in. Run
whoorwto see active sessions. If there are many sessions from the same user, you may need to kill some. - Identify the limit source. The error can come from PAM’s
pam_limitsmodule, which enforcesmaxloginsormaxsysloginsin/etc/security/limits.confor files in/etc/security/limits.d/. Check those files:grep -r maxlogins /etc/security/limits.conf /etc/security/limits.d/. - If a limit exists, raise or remove it. Edit the file (e.g.,
sudo nano /etc/security/limits.conf) and change the line likeusername hard maxlogins 3to a higher number, or comment it out with#. Save and exit. - Check PAM configuration. Some distributions set limits in PAM files like
/etc/pam.d/common-sessionor/etc/pam.d/system-auth. Look for lines withpam_limits.so; if missing, addsession required pam_limits.soto enable the limits module. If the error is about failed logins, checkpam_faillockorpam_tally2settings. - Clear failed login counters. If the error is due to too many failed attempts, use
sudo faillock --user username --reset(for pam_faillock) orsudo pam_tally2 --user username --reset(for pam_tally2). - Kill idle or stuck sessions. If the user has many sessions, you can terminate them with
pkill -u username(careful, this kills all processes for that user) or useloginctl terminate-user usernameto end all sessions. - Check SSH-specific limits. If the issue is over SSH, look at
MaxSessionsandMaxStartupsin/etc/ssh/sshd_config. Adjust them (e.g.,MaxSessions 10) and restart SSH withsudo systemctl restart sshd. - Verify systemd limits. For systemd-based systems, check
logind.confforUserTasksMaxorKillUserProcesses. Edit/etc/systemd/logind.confand restart withsudo systemctl restart systemd-logind. - Test the fix. Log out of all sessions and try logging in again. If it works, you’re done.
Common Mistakes
- Editing the wrong limits file: Some systems use
limits.d/subdirectory; changes in the main file may be overridden. - Forgetting to restart services: Changes to PAM or SSH configs often require a restart of the relevant service or a reboot.
- Killing all user processes:
pkill -ucan terminate important background jobs; preferloginctlor targeted kills. - Not checking for multiple limit sources: Both PAM and SSH can impose limits, so you need to check both.
Tips
- Use
ulimit -uto see the current user process limit, but note that this is different from login limits. - For temporary fixes, you can use
loginctl terminate-sessionto close specific sessions. - Set a reasonable
maxloginsvalue (like 10) to prevent resource exhaustion while allowing normal use. - Monitor login attempts with
lastorjournalctl -u systemd-logindto see patterns.
Troubleshooting
If the issue persists after following the steps:
- Check for duplicate PAM lines. Some systems have multiple PAM config files; a line in one may override another. Search all files in
/etc/pam.d/forpam_limits. - Look at system logs. Run
sudo journalctl -xeor check/var/log/auth.logfor messages about login limits. The exact error message will guide you. - Test with a different user. If another user can log in, the problem is specific to the user’s configuration or their current sessions.
- Reboot the system. Sometimes a reboot clears stuck sessions and reloads all configurations cleanly.
- Check for malicious activity. If the user has many sessions they didn’t create, it could be a security issue. Investigate with
lastandwho.
Frequently Asked Questions
What does “too many logins” mean exactly?
It means the system has a configured limit on the number of concurrent sessions or failed login attempts for that user, and that limit has been reached.
How do I see the current maxlogins value?
Run ulimit -u for process limits, but for login limits, check /etc/security/limits.conf or use grep maxlogins /etc/security/limits.conf.
Can I change the limit without root?
No, modifying system limits requires root or sudo privileges.
Will changing maxlogins affect existing sessions?
No, the change only applies to new logins. Existing sessions remain until they are closed.
What if I don’t want any limit?
You can comment out the line in limits.conf or set a very high number like 9999. Be aware this could allow resource exhaustion.
Is this the same as “too many authentication failures”?
No, that error is about SSH key or password authentication attempts, not session limits. That is handled by MaxAuthTries in sshd_config.
Related
General steps for current mainstream versions; menus can differ by device and version. See the disclaimer or report an error.
More in this bed
- Fix Device Manager Not Opening in Windows 11
- How to Pause Snapchat Location
- System Restore Points Missing in Windows? Fixes
- Loop Nature Ambience Videos with FFmpeg on Ubuntu
- Install League of Legends on Linux: Full Guide
- Fix Error 0x80070001: Causes & Solutions