# SQL Server: Login failed for user 'x'. (Error 18456)

**Code:** `18456` · **Category:** SQL · **Seen on:** SQL

SQL Server rejected the login — wrong password, wrong authentication mode, or a disabled/missing login.

## Meaning

The server error log has a State number that explains the reason (e.g. 8 wrong password, 5 invalid user, 38 database not accessible, 58 SQL auth disabled).

## Common causes

- Wrong password
- SQL Server in Windows-only authentication mode
- Login has no access to the default database
- Login disabled or locked

## Quick fix

1. Check the State in the SQL Server error log
2. Enable mixed mode authentication and restart
3. Map the login to a database user / fix the default database

## Detailed fix by platform

### SQL

1. `ALTER LOGIN app WITH PASSWORD = 'NewStrongPass!1', CHECK_POLICY = ON;`

## How to diagnose

1. **State** — Which state in the error log?
2. **Auth mode** — Mixed enabled?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/sql/mssql-login-failed-18456)
