Support our 100% FREE Projects: Donate Now OR Sponsor Now


  

Microsoft sql server error 18456 login failed for user

In this blog post I will show you reasons why you might be getting SQL Server error 18456 and show you may be able to solve it.

Contents

18456 Error overview

When connecting to Microsoft SQL Server and trying to use usually SQL Authentication method you may get event ID error 18456 login failed for user you provided. See below example.

 Microsoft sql server error 18456 login failed for user

This usually means that your connection request was successfully received by the server name you specified but the server is not able to grant you access for a number of reasons and throws error: 18456. This eventID sometimes provides also state 1 which actually isn’t that useful as due to security reasons any error is converted to state 1 unless you can check logging on the server. Microsoft does not provide very useful message boxes so below are some explanations why you get the error.

Below is a list of reasons and some brief explanation what to do:

SQL Authentication not enabled: If you use SQL Login for the first time on SQL Server instance than very often error 18456 occurs because Windows Authentication (only) is set in Server properties (security section).

To Access Server Properties, Open SSMS, go to Object Explorer pane (use view if you can't see it). Use the connect button to connect to database engine for your server. Once connected you will see it in object explorer. Right click server and click properties. Server Properties window will appear.

microsoft sql server error 18456 login failed for user server properties

See below screenshot that might be causing SQL login to fail

18456 windows authentication
You should set Server Authentication to SQL Server Windows Authentication Mode (see below). Once you select SQL Server Authentication you have to restart the server.

18456 sql authentication

Restart required: You have to restart the service when you change server authentication but bear in mind if someone hasn't restart the service this might be the reason why you get 18456. Remember service restart should be carefully planned on production servers as it will clear certain information (cache) and may impact performance of the server.

NOTE: I recently tried to restart service using SSMS 2012 on Windows 7 and it didn't work.... actually the message below was hidden behind SSMS window and I just did not see it so ensure you get this message when you decide to restart the service. 

18456 restart required


Invalid userID: SQL Server is not able to find the specified UserID on the server you are trying to get. The most common cause is that this userID hasn’t been granted access on the server but this could be also a simple typo or you accidentally are trying to connect to different server (Typical if you use more than one server)

Invalid password: Wrong password or just a typo. Remember that this username can have different passwords on different servers.

less common errors: The userID might be disabled on the server. Windows login was provided for SQL Authentication (change to Windows Authentication. If you use SSMS you might have to run as different user to use this option). Password might have expired and probably several other reasons…. If you know of any other ones let me know.

18456 state 1 explanations: Usually Microsoft SQL Server will give you error state 1 which actually does not mean anything apart from that you have 18456 error. State 1 is used to hide actual state in order to protect the system, which to me makes sense. Below is a list with all different states and for more information about retrieving accurate states visit Understanding "login failed" (Error 18456) error messages in SQL Server 2005
 

ERROR STATE ERROR DESCRIPTION
State 2 and State 5 Invalid userid
State 6 Attempt to use a Windows login name with SQL Authentication
State 7 Login disabled and password mismatch
State 8 Password mismatch
State 9 Invalid password
State 11 and State 12     Valid login but server access failure
State 13 SQL Server service paused
State 18 Change password required


I hope that helped you solve you 18456 error. If you know of another cause and solution than let us know and we will include it in the blog post.

Take care
Emil

Share: Share on FacebookShare on Google PlusTweet it
Comments Add Comment
Name: Yusri
Comment: Nice inpoh
Date Posted: 24/11/2011 9:49:01 AM

Name: Glen
Comment: Spot on. Thanks for the information
Date Posted: 04/12/2011 7:09:24 PM

Name: Michał
Comment: I have similar problem but I use to login user from domain 'domain\user', I have set SQL authentication, additionaly I try to login from computer which is in other domain, I receive error: Login failed for user 'domain\user'. (Microsoft SQL Server, Error: 18456), do you have any suggestion?
Date Posted: 08/12/2011 5:04:58 PM

Name: Ed
Comment: Hello, I have same problem. I just change the date of my server (dec 2012) and now i can't connect to SQL, i have this error.
Date Posted: 13/12/2011 10:31:20 AM

Name: Emil
Comment: Hi Michal. I did get your email. For benefit of other people I will share my comment. If you try to connect to a different domain (for instance using VPN) you might have to sometimes open SSMS from command line as domain/username and that sometimes work (at least for me in current work). Regarding domain\username I don't think that relates to SQL Authentication. I might be misunderstanding your comment here.
Date Posted: 13/12/2011 2:45:38 PM

Name: Emil
Comment: Ed, I have not come across that before but I would change the date back to correct value and restart database engine service (services.msc) and try again.
Date Posted: 13/12/2011 2:47:18 PM

Name: Rajesh
Comment: this the error i m facing while login first time in window Authentication Mode =================================== Login failed for user 'A\rajanarora'. (.Net SqlClient Data Provider) ------------------------------ For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&EvtSrc=MSSQLServer&EvtID=18456&LinkId=20476 ------------------------------ Server Name: A Error Number: 18456 Severity: 14 State: 1 Line Number: 65536 ------------------------------ Program Location: at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) at System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean enlistOK) at System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, Int64 timerExpire, SqlConnection owningObject) at System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(String host, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, Int64 timerStart) at System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance) at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance) at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection) at System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup) at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) at System.Data.SqlClient.SqlConnection.Open() at Microsoft.SqlServer.Management.UI.VSIntegration.ObjectExplorer.ObjectExplorer.ValidateConnection(UIConnectionInfo ci, IServerType server) at Microsoft.SqlServer.Management.UI.ConnectionDlg.Connector.ConnectionThreadUser() Pls help, thanks
Date Posted: 29/12/2011 1:43:47 PM

Name: Emil
Comment: Hi Rajesh. You may try to check this link http://technet.microsoft.com/en-us/library/bb326612.aspx that describes 18456 windows authentication. If you still have the issue please provide sql server version and windows version. Regards Emil
Date Posted: 03/01/2012 11:29:11 PM

Name: No Good
Comment: This looks like it would resolve my problem if the author had bothered to explain how you get to the Server Properties settings. I'm dealing with SQL for the first time in my life and have now encountered this problem and it isn't obvious how you get to those settings.
Date Posted: 18/01/2012 2:35:06 PM

Name: Francine
Comment:

No Good - yep I agree. Did you find out where that is located?


Date Posted: 22/02/2012 4:45:34 PM

Name: Francine
Comment:

found it - have to get into MS SQLServer Management Studio Express - > secutiry> Logins

now just have to work with my hosting company to find out how to get it changed


Date Posted: 22/02/2012 5:02:15 PM

Name: Emil
Comment:

Hi Everyone

Thanks for the comments. I will add extra screenshots soon and try to write posts to cover your comments.


Date Posted: 24/02/2012 8:40:22 PM

Name: Mac
Comment:

This is all completely useless seeing that the error is preventing me from connecting to the database, so how exactly does one intend to change the authentication method if one can't get in?


Date Posted: 06/03/2012 1:52:58 PM

Name: Emil
Comment:

Hi Mac,

This article is for people who manage databases and have windows authentication access to the database and have permissions to perform these actions.

You cannot change authentication if SQL authentication is not enabled and you try SQL Authentication method, SQL Authentication user is also rarely given this kind of permissions due to security.

 


Date Posted: 07/03/2012 8:15:47 AM

Name: ispurmjay
Comment:

You Update ur server ,Install sp1 


Date Posted: 30/06/2012 5:55:45 AM

Name: Glenn
Comment:

 Any one try to connect a 32bit ODBC connection and get 
 

Connection Failed:

SQLState: '28000'
SQL Server Error: 18456
[]Microsoft][SQL Server Native Client 10.0][SQL Server]Login failed for user 'domain\username'.

I have verified that I"m a user, I'm a domain admin and own the DBO rights to the database.  Any help would be nice.  Thanks


Date Posted: 03/07/2012 10:35:21 PM

Name: Usha Gupta
Comment:

Nice. Supper. Thanks


Date Posted: 06/07/2012 11:30:59 AM

Name: Usha Gupta
Comment:

Nice. Supper. Thanks


Date Posted: 06/07/2012 11:31:26 AM

Name: W@rfi
Comment:

Thanks, your post has really helped me ...


Date Posted: 08/07/2012 11:33:00 AM

Name: adb
Comment:

thank you


Date Posted: 10/07/2012 7:37:03 AM

Name: guillaume
Comment:

I hardly comment on blog posts but this time I must say a big *THANK YOU* guys cause I have wasted 2 and a half hours trying to get that stupid thing working. I don't understand why Microsoft makes this whole SQL authentication process being so difficult and yet their support pages don't tell you about that option.

This has been ridiculously hard and painful to find on google and I am glad this page exists.

 

Thanks again !

G


Date Posted: 21/08/2012 9:26:17 AM

Name: Srinivas
Comment:

Thanks a lot for this page. Its helps a lot


Date Posted: 23/08/2012 10:00:05 AM

Name: Alex
Comment:

Sometimes when you create the user and forget to restart the server and services you would have that error message. So I suggest after creating a login, ensure that the server and service are restarted to ensure that you changes take effect.


Date Posted: 27/08/2012 2:08:50 PM

Name: Katie and Emil
Comment:

Thanks for all your comments. It's really nice to see our effort to write good articles is appreciated.

Katie & Emil


Date Posted: 29/08/2012 6:30:05 PM

Name: omprakash
Comment:

Thanks!


Date Posted: 04/09/2012 7:23:48 AM

Name: Kevin
Comment:

Thank you very much for your help.

 


Date Posted: 19/11/2012 7:49:11 AM

Name: Katy
Comment:

Hello, I have head each from sql 2012 installation process. I've installed SQL server 2012 on my computer , and I cannot connect to server with my user account, It's strange ,I have uninstalled SQL and installed again , but it just does not work. Could you help me, please ?


Date Posted: 26/11/2012 12:45:53 PM

Name: Emil
Comment:

Hi Katy,

If you perform the installation yourself than generally it should cause any issues. I suspect you get 18456 error? when you connect to database engine do you select windows authentication (without typing your credentials)? I suspect you added yourself during the setup as admin?

Regards

Emil


Date Posted: 27/11/2012 7:21:03 PM

Name: Vincent
Comment:

Hello,

I meet an error message when I try to connect on Database Engine with a Windows Account. (Error 18456, state 1)

This problem is very strange because when I try to connect to other server type (analysis services, report services, ...), it is a success with a Windows account.

I verify in 'Server Properties' and the option 'SQL Authentification and Windows Authentification' is selected.

For information, I use SQL Server 2008.

Thanks for your help

Vincent


Date Posted: 19/12/2012 8:38:09 AM

Name: arul
Comment:

Thanks for your detailed answer. I have solved the issue


Date Posted: 22/12/2012 5:05:11 AM

Name: Shannon
Comment:

Presented clearly, very helpful. Thx.


Date Posted: 16/01/2013 9:08:54 PM

Name: reetika
Comment:

thanku..... its really helpful for me.....:)

 


Date Posted: 06/02/2013 9:42:42 AM

Name: balaram
Comment:

Thanks a lot...it help me to solve the issue.


Date Posted: 07/03/2013 7:33:15 AM

Share your thoughts, questions and suggest improvements:
Add Comment

You found us! Below are 50 most popular searched keywords

created at TagCrowd.com

Disclaimer: While every caution has been taken to provide our readers with most accurate information and honest analysis, please use your discretion before taking any decisions based on the information in this blog. Author will not compensate you in any way whatsoever if you ever happen to suffer a loss/inconvenience/damage because of/while making use of information in this blog.