How To Resolve SQL error 4060

SQL is used to store and manage relational data. Many users encounter SQL error 4060 and a message “Server rejected the connection; Access to the selected database has been denied” is displayed. Generally, Windows servers show this error after there has been a website migration.

In this article, we shall discuss the causes and all the possible solutions to fix this error permanently on your system.


Causes for SQL Server Error 4060:

Users can get this SQL error 4060 after a website migration has been performed. You would receive this message on your website: “Server rejected the connection; Access to the selected database has been denied”. According to this message, the database cannot be accessed by the network.

SQL server error 4060 can occur due to mainly three causes. The solution for them is quite easy to follow. Below, we will discuss the causes as well as their solutions.

  • No Permissions for Credentials

When the user cannot get permission for database access, the SQL server error 4060 generates. Many users get this error and to avoid this error, users present in the environment before migration should be set up again in the after-migration newer environment with the same required permissions and privileges.


Users tend to miss this point quite often. Users can have the right permissions granted to them with the help of a TSQL command. The command format is mentioned below:

GRANT <permission> [ ,…n ]

TO <database_principal> [ ,…n ] [ WITH GRANT OPTION ]

[ AS <database_principal> ]

Let us take an example. The following TSQL command will be used to provide SHOWPLAN permission to the application role moderator in the following sample snippet:

USE Sample;



  • Protocol Not Enabled

The network protocol has to be in an ‘enabled’ state if you want to establish a connection to the SQL server database engine, otherwise, it will throw the SQL 4060 error. 


The network protocol can be enabled by following the below-mentioned steps:

  1. Click on the Start button.
  2. Choose SQL Server Configuration Manager from the program list.
  3. Now, go to SQL Server Configuration Manager. Then click on SQL Server Network Configuration and finally click on Protocols for <machine instance name>.
  4. Open Named Pipes. 
  5. In the Named Pipes Properties screen, select Yes for “Enabled”. Then click on the Ok button.
  6. We can also enable TCP/IP by selecting TCP/IP in step 4. 
  7. On the TCP/IP Properties screen, select Yes for “Enabled” under the Protocol tab. Under the IP Addresses tab, select Yes for desired IP address. Make sure the required TCP Port is displayed. 
  8. Click on the Ok button. Then restart the server instance from SQL Server Management Studio.
  • Access Blocked by Firewall

The system firewall can restrict the connection and cause SQL error 4060. This can be easily fixed. 


We can fix this by giving access to the firewall. In most cases, the firewall can close a port as a restriction measure. When we open this port by configuring the firewall, the SQL 4060 will be resolved completely.


In this article, we have discussed in great detail the SQL error 4060. It can be caused by firewall restrictions, disabled protocol, and no permission for credentials. We have also covered proper solutions for the SQL server error 4060.