Skip to content

How to Fix macOS Keychain Locked / Not Unlocking

DodaTech Updated 2026-06-24 3 min read

In this tutorial, you'll learn about How to Fix macOS Keychain Locked / Not Unlocking. We cover key concepts, practical examples, and best practices.

The Problem

Your Mac repeatedly prompts for the keychain password:

An application wants to access the keychain "login".
Enter the keychain password to allow this.

Or apps fail to access saved passwords:

The operation couldn't be completed. (OSStatus error -25293.)

The login keychain is locked or the keychain password no longer matches the user account password.

Quick Fix

Step 1: Unlock the keychain via command line

security unlock-keychain ~/Library/Keychains/login.keychain-db

Enter your login password when prompted. This unlocks the keychain for the current session.

Step 2: Update the keychain password to match the login password

security set-keychain-password ~/Library/Keychains/login.keychain-db

You are prompted for the old keychain password (if known) and the new password. The new password should match your macOS login password.

Step 3: Run Keychain First Aid

  1. Open Keychain Access (from Utilities)
  2. Click Keychain Access > Keychain First Aid
  3. Enter your administrator credentials
  4. Click Start

Keychain First Aid verifies and repairs keychain files.

Step 4: Reset the login keychain

If you forgot the keychain password:

  1. Open Keychain Access
  2. Right-click login in the left sidebar
  3. Select Delete Keychain "login"
  4. Log out and log back in

macOS creates a new empty login keychain. You will need to re-enter saved passwords.

Step 5: Reset the default keychain

security default-keychain -d user
security list-keychains -d user -s login.keychain
security default-keychain -s ~/Library/Keychains/login.keychain-db

Step 6: Fix iCloud Keychain sync

  1. System Preferences > Apple ID > iCloud
  2. Toggle Passwords & Keychain off and back on
  3. Enter your iCloud password

Step 7: Delete corrupted keychain files

cd ~/Library/Keychains/
ls -la

If you find multiple login.keychain-db files with strange names, move them aside:

mv login.keychain-db login.keychain-db.backup

Log out and back in to generate a fresh keychain.

Step 8: Check for keychain locking settings

In Keychain Access > Edit > Change Settings for Keychain "login":

  • Lock after X minutes of inactivity: Set to a longer interval or "Never"
  • Lock when sleeping: Uncheck if convenient

Prevention

  • Keep the login keychain password in sync with your macOS login password.
  • Unlock the keychain once per session rather than repeatedly.
  • Back up keychains regularly via Keychain Access > File > Export.

Common Mistakes with keychain locked

  1. Using return to exit a function early instead of wrapping a pure value in the monad
  2. Mixing let bindings with <- bindings in do notation, producing type errors
  3. Overlapping type class instances that cause GHC to reject the program with ambiguous dispatch errors

These mistakes appear frequently in real-world MACOS code. DodaTech's contributors have identified these patterns through analysis of open-source projects and production systems.

Practice Exercise

Write a pure function that safely divides two integers using Maybe, then test it with edge cases like division by zero and negative numbers.

This exercise reinforces the concepts covered in this guide. Try implementing it before checking online solutions.

FAQ

### What happens if I delete the login keychain?

macOS creates a new empty login keychain on next login. All previously saved passwords (Wi-Fi, websites, apps) are lost and must be re-entered.

What is the default keychain password?

The login keychain password is set to the user's login password by default. If it does not match, macOS prompts for it repeatedly.

How do I stop the "keychain unlock" dialog from appearing?

Unlock the keychain once and change the auto-lock settings to "Never" in Keychain Access.

DodaTech Tool Reference

Durga Antivirus Pro's Password Manager integrates with the macOS Keychain to audit saved credentials and flag weak or reused passwords across your applications.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro