Unable to Connect to SQL Server on a Azure VM - sql-server

I have followed this article to help setup and configure SQL Server on a Azure VM and have a heck of time trying to figure out why I can't connect from my ASP.NET web app running a EC2 VM.
http://azure.microsoft.com/en-us/documentation/articles/virtual-machines-provision-sql-server/#SSMS
I have tried tweaking the connection string different ways and of course get different messages. Here is the latest one I am focusing on.
'The requested name is valid, but no data of the requested type was found'
Here is my connection string:
Server=tcp:XXXXXX.cloudapp.net;User ID=XXX;Password=XXXX;Database=XXX;trusted_connection=false; integrated security=false; encrypt=true;TrustServerCertificate=True
Port 1433 is open on the server and I can connect via my local SQL Server without any problems. Ideas why I wouldn't be able to connect from a web app? I verified domain access via nslookup.

The instructions you followed specify the Public VM endpoint should have port 57500 (publicly exposed) and mapped to 1433 internally. Since you're connecting from AWS EC2, it would definitely be connecting over the internet and therefore using your public VM TCP Endpoint, so you'll need to specify the port explicitly in your connection string:
Server=XXXXXX.cloudapp.net,57500;User ID=XXX;Password=XXXX;Database=XXX;trusted_connection=false; integrated security=false; encrypt=true;TrustServerCertificate=True
(Note the syntax involves a comma as opposed to a colon port separator in connection strings).
The connection string example at the bottom of the instruction article you followed fails to specify that you need to specify the port to your instance.
Also, it is worth double-checking in Sql Server Configuration Manager that the server instance has a fixed port for TCP/IP and that TCP/IP is enabled; named instances by default will use dynamic ports, which are difficult to work with behind firewalls. A good overview of general Sql Server ports behavior (1433 vs 1434, etc) is here: http://msdn.microsoft.com/en-us/library/ms175483(v=sql.105).aspx

A very commonly skipped step is to not enabling TCP\IP for your installed instance of SQL Server. Details are here:
https://learn.microsoft.com/en-us/azure/azure-sql/virtual-machines/windows/ways-to-connect-to-sql#manualtcp
The relevant portion is:
In SQL Server Configuration Manager, in the console pane, expand SQL Server Network Configuration.
In the console pane, click Protocols for MSSQLSERVER (the default instance name.) In the details pane, right-click TCP and click Enable if it is not already enabled.
In the console pane, click SQL Server Services. In the details pane, right-click SQL Server (instance name) (the default instance is SQL Server (MSSQLSERVER)), and then click Restart, to stop and restart the instance of SQL Server.

Related

SQL Server 2012 not able to connect to named instance remotely with ssms

I'm running SQL Server 2012 on a Microsoft Windows Server 2012 R2. I am running a named instance called PP. The server authentication is set to "SQL Server and Windows Authentication mode".
When I am logged into the server via Remote Desktop I can log in to the named instance via SSMS just fine using a using a SQL Server username and password. When I try to log into the named instance remotely using the same username and password I get an error as described in this screenshot (my reputation isn't high enough to paste the screenshot directly in my post, please follow the link):
Here are the things I have checked so far:
I can ping the IP Address of the remote server from my local computer and get successful responses.
I have configured the instance of SQL Server to accept remote connections as described in this article.
In SQL Server Configuration Manager on the remote server under the protocols for my named instance I have enabled "Shared Memory", "Named Pipes" and "TCP/IP".
Under "TCP/IP" properties on the remote server in SQL Server Configuration Manager in the "IP Addresses" tab under the "IP2" section I have set the "TCP Dynamic Ports" value to blank. I have tried setting the "TCP Port" value to 1433 and then to 1434 (the difference between a regular instance and a named instance) and going through the rest of the steps below as shown in the screenshot here (these are the values specified in the article I linked to above)
Windows firewall is not running on the remote server, and from what I can see there is not another firewall running on the remote server either.
The SQL Server Browser service on the remote server has been stopped and restarted.
After I have made all of these changes and verified all of these settings the SQL Server service for the named instance on the remote server has been stopped and restarted.
After all of this I am still getting my original error when I try to connect to the named instance of SQL Server on my remote server from my local computer via SSMS. I've been searching high and low and cannot find any additional troubleshooting steps to diagnose this problem. Will someone please point me in the direction of the next steps I should take to fix this? Thanks in advance.
I logged off and then came back the next day to implement the suggestions in #Andrey Nikolov 's answer and for some reason I am able to connect remotely to the named instance now. The settings that ended up working for the "IP2" section of the "TCP/IP" configuration for the named instance are the "TCP Dynamic Ports" value is set to blank and the "TCP port" is set to 1433. I didn't make any other changes. The rest of the configuration is as I noted in my OP. I have sysadmin access to this server but I'm not the actual administrator so I guess it's possible that the actual administrator might have changed something else between when I logged off and then logged back on but I don't know what that might be. Thanks to #Andrey Nikolov for your input.
EDIT:
This issue came back in full force a few days later for no reason that I could determine. After a long search I found a very informative MS Doc that goes through the whole troubleshooting process for this in depth, hope this helps someone else confronted with this. Here's the link:
https://learn.microsoft.com/en-us/sql/database-engine/configure-windows/troubleshoot-connecting-to-the-sql-server-database-engine?view=sql-server-2017
It says it's for SQL Server 2017 but I was able to follow it to fix my SQL Server 2012 issue. For my situation it turns out that because I had 2 separate instances of MS SQL on my server the initial instance was using all of the default settings as described elsewhere and my instance I was trying to connect to was using a completely different port. Using this Doc I was able to find out what port my instance is using and specify that in the "Server name" box of SSMS when I tried to connect. Now it works like a charm.
I think your named instance TCP/IP isn't configured properly. In case you connect locally it does not connect using TCP/IP, but using shared memory. You set your instance to listen on port 1434, but this port is used by SQL Browser service and most likely the SQL Server engine service can't open the port (you can confirm that by finding the error in the logs). To make it work you should set IP2 -> TCP Dynamic Ports to be 0 and clear IP2 -> TCP Port. Configured like this, your named instance will use dynamic ports. If you want to configure it to use specific port, replace 1434 in IP2 -> TCP Port with available port number.

Sharepoint 2013 configuration wizard -Failed to create the configuration database

When run Sharepoint 2013 configuration wizard, I get an error at step 3-Failed to create the configuration database:
An exception of type System.ArgumentNullException was thrown. Additional exception information: Value cannot be null.
Parameter name: password
Also,
- Sharepoint_config database created in SQL server
- Try to reinstall Sharepoint
- Try to reinstall SQL server
But, the error still there.
Anyone has idea? Help please
Update: I found some sites added to IIS. May I add these sites previous time with older password. By delete these site, re-run configuration wizard, it passes issue and complete successfully.
Thank you all for your comment
There are many reasons why:
SQL database and services are down.
The SQL database may not be running correctly
You applied a Hotfix or Service Pack and did not reboot.
The Firewall is blocking the communication
The SharePoint Installation Account does not have the required permissions to the SQL Server database.
Network connectivity is not optimal between the SharePoint Server and SQL Server.
Troubleshooting steps
Check logs:
Review the PSCDiagnostics log at, C:\program files\common files\Microsoft shared\web server extensions\15 or \14 for the SharePoint logs
This is the kind error that you can receive with maybe more information: System.Data.SqlClient.SqlException was thrown. Additional exception information: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (Provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
Verify that the SQL database is running and services.
In the list of services, locate the MSSQLSERVER service and be sure that it’s running.
Be even sure that on the Microsoft SQL Server, the following services are running:
SQL Browser (if your aren’t using the default instance name)
All other SQL services
3. Firewall
Firewall can block access and communication with your Microsoft SQL Server so you have 2 possibilities.
Disable Firewall, easiest way on development machine but not secure and recommended for a Production environment.
So you can create 2 rules on the Firewall:
One inbound TCP rule with ports:1433,2383,2382
One inbound UPD rule with port: 1434
1433: SQL Server is a Winsock application that communicates over TCP/IP by using the sockets network library. SQL Server listens for incoming connections on a particular port. The default port for SQL Server is 1433. The port doesn't need to be 1433, but 1433 is the official Internet Assigned Number Authority (IANA) socket number for SQL Server.
2383: TCP port 2383 should be open when installing a default instance or creating an Analysis Services failover cluster.
2382: TCP port 2382 should be open when installing a named instance. Named instances use dynamic port assignments. As the discovery service for Analysis Services, SQL Server Browser service listens on TCP port 2382 and redirects the connection request to the port currently used by Analysis Services.
1434: the client computer would need to open a random UDP port and the server UDP port 1434 will be used to send the instance name, and if the instance is clustered, the version of the SQL instance, the TCP port number that the instance is listening on, and the named pipe that the instance is using. However, if the goal is to minimize the number of ports open on the firewall, a static port number should be chosen for the default instance and any named instance. The client computers would need to be configured to connect to a particular ServerName or ServerName instance and specific port number.
Is your SQL configured correctly?
Is actually your SQL server correctly setup? Are you sure about the steps that you executed? If not please check here. All these links are official TechNet articles:
Installation how-to Topics This link is external to TechNet Wiki. It will open in a new window.
Install SQL Server 2012 on Server Core This link is external to TechNet Wiki. It will open in a new window.
Validate a SQL Server Installation This link is external to TechNet Wiki. It will open in a new window.
Check Parameters for the System Configuration Checker This link is external to TechNet Wiki. It will open in a new window.
Product Updates in SQL Server 2012 Installation This link is external to TechNet Wiki. It will open in a new window.
Configure the Windows Firewall to Allow SQL Server Access This link is external to TechNet Wiki. It will open in a new window.
User Permissions
Next, you have to verify that your account has the required permissions on the SQL Server database.
Click Start, point to Programs, point to Microsoft SQL Server, and click Enterprise Manager
In the left pane, double-click Microsoft SQL Servers, and then double-click your SQL server group.
Double-click your server.
Double-click Security.
In the left pane, click Logins.
In the right pane, double-click the user for your Farm Admin Global Administrator.
In the SQL Server Login Properties dialog box, click Server Roles.
And select the following: Security Administrators and the Database Creators check boxes and then click Database Access.
Can they talk to each other?
Verify that SharePoint is using the correct IP address for the SQL server. To do this, run the ping command on the Windows SharePoint Services server.
Verify that the SharePoint server is obtaining the correct IP address for the SQL server from DNS. To do this, run the nslookup command from the SharePoint Server.
Make sure that there are no incorrect entries for the SQL server. To do this, examine the Hosts file on the SharePoint server. This file is in the following location:
%systemroot%\system32\drivers\etc\Hosts
On the SharePoint server, look for SQL client aliases. To do this, follow these steps: Click
Start, click Run, and then type cliconfg in the open box.
Click the Alias tab. By default, there are no SQL client aliases. If you have any aliases for the SQL server, verify that they are correct, or remove them.
Open the SQL Server Configuration Manager (Start SQL Server 2008 Configuration Tools SQL Server Configuration Manager
Navigate to the SQL Server Network Configuration Protocols for MSSQLSERVER node in the tree view
Enable TCP/IP and Named Pipes (you’ll be warned that these changes will not apply until the service is shut down)
SID
Please be sure that if you made a copy of a Virtual Machine that you used sysprep before to avoid getting the same SID! You can use PSTOOLS to change this if it’s not the case.
First, click to Start->Run, type sysprep and press OK.
This will open sysprep folder which is located in c:\Windows\System32. Open sysprep application.
This will open System Preparation Tool 3.14 window. As a System Cleanup Action select Enter System Out-of-Box Experience (OOBE). Important: select generalize if you want to change SID, it’s not selected by default. As Shutdown Options select Reboot.
After rebooting you’ll have to enter some data, for example, Country or region, Time and currency and Keyboard input.
Reset Database-connection-timeout and is your DB up-to-date
Follow the http://technet.microsoft.com/en-us/library/cc263314.aspx http://social.technet.microsoft.com/wiki/cfs-file.ashx/__key/communityserver-components-sitefiles/10_5F00_external.png This link is external to TechNet Wiki. It will open in a new window. and change the timeout to 45 with the next command: stsadm -o setproperty -pn database-connection-timeout -pv 45
Click Start, click Run, type cmd in the Open box, and then click OK.
Change to the following directory: system drive\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\Bin
Run the following command:
psconfig -cmd upgrade -inplace b2b
In SQL Server Configuration Manager, in the console pane, expand SQL Server Network Configuration, expand Protocols for , and then double-click TCP/IP.
If the TCP Dynamic Ports dialog box contains 0, indicating the Database Engine is listening on dynamic ports, delete the 0.
If the TCP Port box isn’t 1433, type the port number 1433 and then click OK.
In the console pane, click SQL Server Services.
In the details pane, right-click SQL Server () and then click Restart, to stop and restart SQL Server.
To assign a TCP/IP port number to the SQL Server Database Engine
In SQL Server Configuration Manager, in the console pane, expand SQL Server Network Configuration, expand Protocols for , and then double-click TCP/IP.
If the TCP Dynamic Ports dialog box contains 0, indicating the Database Engine is listening on dynamic ports, delete the 0.
If the TCP Port box isn’t 1433, type the port number 1433 and then click OK.
In the console pane, click SQL Server Services.
In the details pane, right-click SQL Server () and then click Restart, to stop and restart SQL Server.
SharePoint administrative accounts: Local Administrator
The installation account is used to set up each server in your farm by running the SharePoint Configuration Wizard, the initial Farm Creation Wizard, and Windows PowerShell. For the examples in the setup user administrator account is used for farm administration, and you can use Central Administration to manage it. Some configuration options, for example, configuration of the SharePoint 2013 Search query server, require local administration permissions. The setup user administrator account requires the following permissions:
It must have domain user account permissions.
It must be a member of the local administrators group on each server in the SharePoint farm, excluding the server running SQL Server and the Simple Mail Transfer Protocol (SMTP) server.
Please check this: http://social.technet.microsoft.com/wiki/contents/articles/6545.aspx

Connecting SQL Server Virtual Machine to Web Role in same Azure Virtual Network

I'm attempting to set up a Virtual Network in Windows Azure and use it to avoid opening a public endpoint on my (CUSTOM) SQL Server Virtual Machine. However, I continuously get a network related error, stating that the SQL Server wouldn't talk back in time, when trying to access my web application via my cloud service's URL.
I've looked all over the net for tutorials that show how to connect to one's own Custom-created VM instead of one of Windows Azure's preconfigured Virtual Machines, and found little of use. All the suggestions I've found I've tried.
I am working in Windows 7, using Visual Studio 2010 with the Windows Azure SDK installed, SP1.
Here are some details of what I have attempted to do to no avail.
I have:
created the Virtual Network with
its own Affinity Group
a single Subnet
added the Virtual Machine to it
making sure to put it in the same affinity group as the one I created for the VNet
installed SQL Server
configured SQL Server as per this tutorial
Added my databases and a login that I have verified can access the database
Both:
Converted an existing Asp.NET Website to a Web App and added a Azure Deployment Package thing see here for the tutorial I followed
I used r-click->Publish to Azure/Publish for this one, configured to use an existing Cloud Service I had already deployed in the VNet with the SQL VM, and made sure it was in the same Subnet as the VM.
it is also worth noting that this application did connect to a similar VM that was deployed outside the Virtual Network (still in Azure) by opening a public endpoint on port 1433 and using the Public IP address to connect to it.
Used the converted Web App's code in a brand new Azure Cloud Service project configured as per this tutorial (the first one I mentioned)
I attempted both publishing by:
r-click->Publish to Azure/Publish
r-click->Package and uploading it on the Azure Portal
in both cases both to
an existing Cloud Service in the VNet (and Subnet)
and a brand new Cloud Service created in the VNet (and Subnet) and upload package during creation or immediately publish to service as soon as started.
Double checked that all Cloud Services and Virtual Machines I've gone through were in the VNet, and in the same Subnet.
My Cloud service is usually at internal IP 10.4.2.5, and the VM at 10.4.2.4. My connection string is the same as the first tutorial I mentioned only with the proper authentication and my VM's internal IP specified. Connection string follows:
<add name="SQLServerinWAConnection"
connectionString="Data Source=tcp:SQLVMInternalIPAddress;Initial Catalog=MyTableName;User ID=loginName;Password=thepassword;Encrypt=true;Trusted_Connection=false;TrustServerCertificate=true"
providerName="System.Data.SqlClient" />
I also tried specifying Trusted_Connection=true
No matter what I try, I cannot get this application to connect to the SQL Server instance on that VM. I have even added a public endpoint to the VM at port 1433 and tried using its public IP and private IP, to no avail. That was my fallback, so now I'm at a serious loss.
Some implementation details that may or may not have any bearing:
The SQL Server instance is named, not default, so instead of just 'SQLServerVM' in the object explorer in SQL Server Management Studio, it has 'SQLServerVM\SQLServerDB'.
I have the port 1433 opened on the firewall on the VM for any IP range and any user
I will add any additional details (in case you don't want to read the whole tutorials to figure out what I've done) upon request.
There isn't by any chance a checklist available to state the things which need to be done for a web role or website to be able to connect to a virtual machine in its virtual network? That would greatly simplify troubleshooting.
Any suggestions would be greatly appreciated. I would very much like to have this working by the end of the day.
In my case, since our client installed SQL Server on the VM, using a named database instance, the service which hosted the instance I needed to connect to didn't have its TCP port set properly. So my detail that the SQL Server instance was named was indeed important.
If you just cannot figure out why your Web Role (Cloud Service) just isn't connecting to your Virtual Machine in the same Virtual Network, In addition to checking all of the things above in the question, check the following setting:
Log into the Virtual Machine (RDP)
Open the SQL Server Configuration Manager
Expand "SQL Server Network Configuration" in the left panel.
Click on "Protocols for {SQL Instance name here}" in the left panel.
Right-Click on "TCP/IP" in the right panel, go to "Properties..."
Double check that "Enabled" is set to "Yes".
Switch to the "IP Addresses" tab.
At this point, you should see that the "TCP Port" should be 1433 for at least the domain IP (in my case 10.4.2.4 in the "IP2" section), if not "IPALL" or some others.
Note that the "TCP Port" settings on all the "IP{X}" sections may have different values.
IF you don't see this SQL Server instance listening on 1433 (or some other port you are trying to configure):
Go to "IPALL" and change the "TCP Port" to 1433 (or whatever port you like, 1433 is the default that things will send to).
This will allow that port to be listened on for addresses coming to this server from anywhere.
Note that there is probably a cleaner way to do this, but this worked quite well for us.
This allowed me to access the SQL Server instance from all the Cloud Services in that VNet, using only the Internal IP Address of the VM, without a public endpoint opened for the port I configured (1433).
Just in case, here is the working connection string:
<add name="ApplicationServices"
connectionString="Data Source=tcp:{VM Internal IP}\{InstanceName},{port};Initial Catalog={Table};User ID={username};Password={passwd};Encrypt=true;Trusted_Connection=false;TrustServerCertificate=true" providerName="System.Data.SqlClient"/>
Make sure you replace:
{VM Internal IP} with your internal IP address
{InstanceName} with your SQL Server Instance's name, or leave it and the preceding \ out entirely if you have a default instance.
{port} should either be 1433 or whatever port you set open in your VM for that Sql Server instance.
{Table} with the Database table you want to use by default
{username} and {passwd} with those for your SQL Server user. Note that I am using SQL Server authentication here.
It's also worth noting that this did not open my server up to the internet (as expected), as I still can't get at it from the outside world, so it remains secured within the VNet this way.
Hopefully this will help someone in the future.

Connecting to SQL Server Named Instance from Windows 64bit

I have both java and .net applications running on an app server using Microsoft Windows Server 2003, Enterprise Edition. These are being migrated to another app server Windows 2008 64-bit machine.
All applications connect to the same SQL Server 2005 database, on a named instance.
So far I have tried to move the applications exactly as they are, with no changes in the configuration files, from the old box to the new box.
On the new app server, neither the java nor the .net applications connect to the database (named instance).
JDBC error message: "The connection to the named instance has failed. Error: java.net.SocketTimeoutException: Receive timed out."
The .net error message: "A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible."
If I change the DB config to one that is not on a named instance it works on the new app server.
The database is setup correctly, because we were able to connect on the old app server. I can ping the database server from the new app server.
Is there any reason this won't work on the new app server?
java connection string: "jdbc:microsoft:sqlserver://[dbservername];SelectMethod=Cursor;instanceName=[dbinstance]"
.net connection string: "Server=[dbservername]\[dbinstance];Database=Risk_DB;Uid=[user];Pwd=[pwd];"
UPDATE
Per suggestions in the answers, I got the instance port number. I also installed SQL Server Management Studio so I can eliminate my apps as the problem points. From Management Studio, if I use [servername][instancename], I get the message "a network-related or instance-specific error while establishing a connection to SQL Server..." But it works when i use [servername],[port]. Not sure if there's anyway to work around this?
UPDATE #2 Escalated the issue to the infrastructure/server/network team. They disabled windows firewall on the new app server. Presto, now I can connect to [dbservername]\[dbinstance] in Management Studio, and all apps are working using existing configuration files.
Your named instance is going to be running on a different port. Port 1433 (the default for a default instance) is probably open, and the port that the named instance is running on is probably blocked. You can check the port in the error log for the named instance (assuming you can connect locally, in Object Explorer, expand the server, expand Management, expand SQL Server Logs, right-click current, and choose "View SQL Server Log" IIRC), it will say something like this on startup:
Server is listening on [ 127.0.0.1 <ipv4> 3587 ].
That last number is the port number that needs to be accessible from your remote machine and whatever network devices and services it has to go through to get there. If you don't find a line like that, it's possible that TCP/IP is not enabled for the named instance. On that server, go to SQL Server Configuration Manager, expand SQL Server Network Configuration, click on "Protocols for " and make sure TCP/IP is enabled in the right pane. If you have to enable this you'll need to restart SQL Server for it to take effect.
If it is already enabled (or once you enable it and restart the service), you should be able to refresh this view and validate the port that is being used if you right-click TCP/IP, hit properties, and move to the IP Addresses tab. You can see the ports currently being for each IP. Here there will be multiple IPn sections and an IPAll section. For each IP, you can change the "TCP Port" box to a port you want to use (and delete any values in all the "Dynamic TCP Ports" box to 0). Hit Apply and restart the service. This will again require a restart of the service but will allow you to specify a specific port so you can add an exclusion to your firewall (or make use of one that already exists, assuming this server isn't already using that port).
Possible issues:
Firewall maybe blocking connections.
The instance name is not the same as specified in the connection string.
The connection string specifies a different port or SQL Server is running on a different port rather than the default 1433

Unable to connect to SQL Server instance remotely

I’m trying to access the SQL Server instance on my VPS from SQL Server Management Studio on my local machine. It’s not working (the error I’m getting is:
A network-related or instance-specific error occurred while
establishing a connection to SQL Server. The server was not found or
was not accessible. Verify that the instance name is correct and that
SQL Server is configured to allow remote connections.
I think this is because I need to configure the database engine to allow remote connections (correct me if I’m wrong!). So I’ve found this step-by-step guide to help me do that: http://www.linglom.com/2009/03/28/enable-remote-connection-on-sql-server-2008-express/ I’ve got to point 10 in the guide and I am now stuck! I don’t have SQL Server Management Studio installed on my VPS. Anyway, this has left me with two options:
Install SSMS
Find another way to do point 10 onwards in the guide without having SSMS installed
I tried installing SSMS on my VPS using the Web Platform Installer but it keeps failing. I don’t know why it’s failing because it doesn’t seem to give a reason why. Does anyone know how I could allow remote connections a different way?
The version of SQL Server installed on my VPS is SQL Server 2008 R2 Express.
Update:
I have tried to disable the firewall on both my laptop and VPS to see if it is a firewall issue. This made no difference to the error message.
Another Update:
Having now been able to install SSMS (I installed directly from the website rather than using the WPI), I have been able to check that the server is configured to allow remote connections (I went to SSMS, connected to the SQL Server instance, right-clicked on the connection, clicked Properties, went to the Connections tab. "Allow remote connections to this server" is already ticked).
SOLUTION
Thanks to everyone for helping me get to this solution! I've finally managed to get it to work! I followed Filip De Vos's advice and opened the ports in the Firewall on my VPS and then I received a different error message. This led me to investigate further and I found that I was using the wrong credentials to login! So I've set a password for the sa user and I've managed to login using that! Thanks again!
To enable mixed authentication you can change the following registry key:
HKLM\Software\Microsoft\Microsoft SQL Server\MSSQL.1\MSSQLServer\LoginMode
Update the value to 2 and restart the Sql Server service to allow mixed authentication. Note that MSSQL.1 might need to be updated to reflect the number of the SQL Server Instance you are attempting to change.
A reason for connection errors can be a virus scanner installed on the server which blocks sqlserver.exe.
Another reason can be that the SQL Server Browser service is not running. When this service is not running you cannot connect on named instances (when they are using dynamic ports).
It is also possible that Sql Server is not setup to listen to TCP connections and only allows named pipes.
In the Start Menu, open Programs > Microsoft SQL Server 2008 >
Configuration Tools > SQL Server Surface Area Configuration
In the Surface Area Configuration utility, click the link "SQL Server
Configuration Manager"
Expand "SQL Server Network Configuration" and
select Protocols.
Enable TCP/IP. If you need Named Pipes, then you can
enable them here as well.
Last but not least, the Windows firewall needs to allow connections to SQL Server
Add an exception for sqlserver.exe when you use the "Dynamic Port" system.
Otherwise you can put exceptions for the SQL Server ports (default port 1433)
Also add an exception for the SQL Server Browser. (udp port 1434)
More information:
How to: Configure a Windows Firewall for Database Engine Access
Server Connectivity How-to Topics (Database Engine)
As a last note, SqlLocalDB only supports named pipes, so you can not connect to it over the network.
In addition to configuring the SQL Server Browser service in Services.msc to Automatic, and starting the service, I had to enable TCP/IP in: SQL Server Configuration Manager | SQL Server Network Configuration | Protocols for [INSTANCE NAME] | TCP/IP
Launch SQL Server Configuration Manager on your VPS.
Take a look at the SQL Server Network Configuration. Make sure that TCP/IP is enabled.
Next look at SQL Server Services. Make sure that SQL Server Browser is running.
Restart the service for your instance of SQL Server.
Open the SQL Server Configuration Manager....
2.Check wheather TCP and UDP are running or not....
3.If not running , Please enable them and also check the SQL Server Browser is running or not.If not running turn it on.....
Next you have to check which ports TCP and UDP is using. You have to open those ports from your windows firewall.....
5.Click here to see the steps to open a specific port in windows firewall....
Now SQL Server is ready to access over LAN.......
If you wan to access it remotely (over internet) , you have to do another job that is 'Port Forwarding'. You have open the ports TCP and UDP is using in SQL Server on your router. Now the configuration of routers are different. If you give me the details of your router (i. e name of the company and version ) , I can show you the steps how to forward a specific port.
I had the same issue where my firewall was configured properly, TCP/IP was enabled in SQL Server Configuration Manager but I still could not access my SQL database from outside the computer hosting it. I found the solution was SQL Server Browser was disabled by default in Services (and no option was available to enable it in SQL Server Configuration Manager).
I enabled it by Control Panel > Administrative Tools > Services then double click on SQL Server Browser. In the General tab set the startup type to Automatic using the drop down list. Then go back into SQL Server Configuration Manager and check that the SQL Server Browser is enabled. Hope this helps.
Disable the firewall and try to connect.
If that works, then enable the firewall and
Windows Defender Firewall -> Advanced Settings -> Inbound Rules(Right Click) -> New Rules -> Port -> Allow Port 1433 (Public and Private) -> Add
Do the same for Outbound Rules.
Then Try again.
I recently upgraded from SQL 2008 R2 to SQL 2012 and had a similar issue. The problem was the firewall, but more specifically the firewall rule for SQL SERVER. The custom rule was pointed to the prior version of SQL Server. Try this, open Windows Firewall>Advanced setting. Find the SQL Server Rule (it may have a custom name). Right-Click and go to properties, then Programs and Services Tab. If Programs-This program is selected, you should browse for the proper version of sqlserver.exe.
If you have more than one Instances... Then make sure the PORT Numbers of all Instances are Unique and no one's PORT Number is 1433 except Default One...
Open SQL Server Configuration Manager.
Click SQL Server Services, on the right side choose the server you've created during installation (by default its state is stopped), click once on it and a play button should appear on the toolbar. Click on this play button, wait til its state turns to "Running". Now you're good.
Open SQL Server Management Studio; switch the "Server Type" to "Database Engine" and "Authentication" to "SQL Server Authentication". The default login is "sa", and the password is the password that you chose on creating the server. Now you're good to work.
In my case the problem was caused by the inconsistency between computer names. In system settings my computer was named with some long name, but apparently the name used for some certain communications was trimmed.
I changed the name in the settings to a shorter one and it worked.
I had built both a console app and a UWP app and my console connected fine, but not my UWP. After hours of banging my head against the desk - if it's a intranet server hosting the SQL database you must enable "Private Networks (Client & Server)". It's under Package.appxmanifest and the Capabilities tab.Screenshot
Before download the last version and update your sql server to fix errors of TLS 1.2 on Sql Server 2012. For more information, check here.

Resources