Access database over network - sql-server

I want to access my database over network. It gives error:
Error: Cannot Connect to 192.168.0.2\SQLEXPRESS
I enabled the TCP/IP from SQL Configuration.
I turn off the firewall.
I allow SQL Server Authentication and Windows mode.
and I can ping to the ip-address.
Why I am not able to connect to database?

Try to connect by specifying 192.168.0.2,1433 , here 1433 is port.

Probably is a server configuration problem. Try as follow.
On the server, open SQL Server Configuration Manager
Open SQL Server Network Configuration on the left panel and select Protocols for YOURSERVERNAME.
On the right panel double click on TCP/IP and be sure that Enabled is set to Yes.
Open the tab IP Addresses and set as Yes the Active and Enabled selection boxes where the IP Address is 192.168.0.2.

You're probably using a wrong instance name. If you want to connect to a default one i.e. MSSQLSERVER use either dot (.) or a machine name or an IP address as a sever name.
If you are not sure what is the name of your instance just run SQL Server Configuration Manager. You can find it in Start menu. Then select SQL Server Services and there you should find something like SQL Server (NAME_OF_YOUR_INSTANCE).
It is also worth reading this article and this question.

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.

After changing the TCP ports of named SQL Server instance while logging through SSMS to localhost or . I still login to the old default SQL Server

I have installed named instance of the SQL Server, later I wanted to use it as default instance. So I did this:
Open SQL Server Configuration Manager
Click SQL Server Network Configuration
Click Protocols for INSTANCENAME you want to make available (i.e. SQLExpress)
Right-click TCP/IP and click Enabled
Right-click TCP/IP and go to Properties
Go to the IP Addresses tab
Scroll down to the IPAll section
Clear the field TCP Dynamic Ports (i.e. empty/blank)
Set TCP Port to 1433
Click Ok
Go to SQL Server Services
Right-click your SQL Server (INSTANCENAME) and click Restart
This made my the named instance listen on the default port. Then I did the same for the default server and I changed TCP port to the 1434 so they don't interfere.
I restarted the computer but still when I login through SQL Server Management Studio and give localhost as the server name I still access the old default server.
Why is it so, how to fix it?
when I login through SQL Server Management Studio and give localhost as the server name I still access the old default server
Probably because you are connecting over Shared Memory, not TCP/IP.
EG connect and run
select net_transport
from sys.dm_exec_connections
where session_id = ##spid
If you specify tcp:localhost you should connect to the target instance.
Note in this configuration you'll want to disable the other network protocols to avoid this confusion.

Cannot connect to SQL Server named instance

I cannot connect to a named instance of SQL Server. I am trying to connect to domain\named_instance but this happens to all servers I try to connect to apart from localhost
The error that I cam getting looks like this:
So far I have tried:
Enabling remote connections in SQL Server
Enabling TCP/IP in the SQL Server Configuration Manager
Changing all the TCP ports in SQL Server Configuration Manager to 1433
I also tried running the command below where the number is the Process ID of the SQL Server Service:
netstat -ano | find /i “7608”
My result was as follows:
As suggested by this website.
However I do not get the ESTABLISHED return only the 2 LISTENING ones.
My IP2 IP address is set to: 192.168.2.176not 100% sure if this is right or not.
I cannot (due to security issues with my hosting company) get the IP of the server. Any and all suggestions are welcome!
I am in dire straits, and really need help!
I am using SQL Server 2008
Since you are stating you are trying to use named pipes (can be seen in the screenshots) I think you errornously trying to use TCP configuration to do this.
You need to need to enabled SQL to listen named pipes. How to do - see here.
There are multiple types of error "Cannot connect to 'Server Name'".
These error are differentiated on the basis of Error Additional Information.
One of the Solution for above error is
Connect the server using Windows Authentication.
Right Click on the Server(i.e. first option) in Object Explorer. Then go to Properties.
Go to Security then select Server Authentication as "SQL Server and Windows Authentication Mode"
Again Right Click on the Server(i.e. first option) in Object Explorer. Then select restart.
Then try again login using SQL Authentication

Accessing Host SQL Server From VMWare Machines

I have Windows 7 with SQL Server 2008 and SQL Express 2012 on it. I have also installed win xp on two vmware machines. I am trying my best to connect to sql server on host machine from the vm machines using management studio, but no luck. I had problem even pinging the host machine and visa versa. When I turned off the firewall, I was able to ping the host machine. I tried to add the vm machine's IP to allow access to host machine, but even that didnt work.
I have added a custom rule from here
http://www.rackspace.com/knowledge_center/article/creating-an-inbound-custom-allow-rule-for-windows-firewall-windows-2008
I was running hotspot shield which i turned off, but still no luck. I have allowed remote connection on my sql server. but still not working. Can someone help here.
This is the error I get.
Here is the setting for vm machine.
When the firewall is on, cant ping, but can ping when its off.
Regards
Parminder
You need to configure SQL Server to listen on the TCP protocol. To do this, click Start | All Programs | Microsoft SQL Server 2012 | Configuration Tools and open SQL Server Configuration Manager.
In SQL Server Configuration Manager, expand SQL Server Network
Configuration in the console pane.
Click Protocols for instance name. (The default instance is
Protocols for MSSQLSERVER).
In the details pane, right-click TCP, it should be Enabled for the
gallery images by default. For your custom images, click Enable (if
its status is Disabled.)
Right-click on TCP/IP and select Properties.
Verify that, under IP2, the IP Address is set to the computer's IP
address on the local subnet.
Make sure that TCP Dynamic Ports is blank.
Make sure that TCP Port is set to 1433.
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.
Then, you need to open TCP ports in the Windows firewall for the default instance of the Database Engine. To do this, click Start | All Programs | Administrative Tools, and open Windows Firewall with Advanced Security.
In the Windows Firewall with Advanced Security, in the left pane,
right-click Inbound Rules, and then click New Rule in the action
pane.
In the Rule Type dialog box, select Port, and then click Next
In the Protocol and Ports dialog box, select TCP. Select Specific
local ports, and then type the port number of the instance of the
Database Engine (1433 for the default instance). Click Next.
In the Action dialog box, select Allow the connection, and then
click Next.
In the Profile dialog box, select Domain, Private, Public, and then
click Next.
In the Name page, set the Inbound Rule's Name to SQLServerPort and
click Finish. Close Windows Firewall with Advanced Security window.
Hope this help.
Best Regards
This comes straight from MSDN blog in regards to network error 26. Details here
1) Make sure your server name is correct, e.g., no typo on the name.
2) Make sure your instance name is correct and there is actually such an instance on your target machine. [Update: Some application converts \\ to \ If you are not sure about your application, please try both Server\Instance and Server\\Instance in your connection string]
3) Make sure the server machine is reachable, e.g, DNS can be resolve correctly, you are able to ping the server (not always true).
4) Make sure SQL Browser service is running on the server.
5) If firewall is enabled on the server, you need to put sqlbrowser.exe and/or UDP port 1434 into exception.
If that still fails you might want to run PortQry.
You can download PortQry from here details on application here, run "portqry.exe -n yourservername -p UDP -e 1434". If this command returns information and it contains your target instance, then you can rule out possiblity 4) and 5) above, meaning you do have a SQL Browser running and your firewall does not block SQL Browser UDP packet. In this case, you can check other issue, e.g. wrong connection string.
Note if you're running SQLExpress it still might not work after applying the steps from octavioccl's comment.
What fixed it for me was replacing my SQLExpress 2019 with SQL Server Developer 2019, applying the mentioned SQL Network config and Firewall settings and then I was finally able to connect to the Host's SQL server just by using the hostname, no IPs and ports.

Cannot connect to remote SQL Database with SQL Server Management Console (Error 53)

I have opened up port 1433 on my firewall, but every time I try and connect to my remote SQL Database with SQL Server Management Console I receive (Microsoft SQL Server, Error: 53)
https://social.technet.microsoft.com/wiki/contents/articles/2102.how-to-troubleshoot-connecting-to-the-sql-server-database-engine.aspx
http://blog.sqlauthority.com/2009/05/21/sql-server-fix-error-provider-named-pipes-provider-error-40-could-not-open-a-connection-to-sql-server-microsoft-sql-server-error/
http://blogs.msdn.com/b/walzenbach/archive/2010/04/14/how-to-enable-remote-connections-in-sql-server-2008.aspx
Enable remote connections for SQL Server Express 2012
Short Answer
Check Firewall
Check Service is Running
Check TCP/IP is Enabled
Check SQL Server Properties "Allow Remote Connections"
Check if the SQL Server is on a restricted subnet
Then Run these if Those Do not Resolve
Right-click on TCP/IP and select Properties.
Verify that, under IP2, the IP Address is set to the computer's IP address on the local subnet.
Scroll down to IPAll.
Make sure that TCP Dynamic Ports is blank.
Make sure that TCP Port is set to 1433.
If you have a named instance then you must have the SQL Server Browser Service enabled
The browser service runs on port UDP 1434 and this must be allowed through your firewall
Hail Mary Pass if this is Still not Resolved
Go to the client machine, and run cliconfg.exe If named pipes is listed first, demote it, and promote TCP/IP.
check if the firewall is blocking the named pipes port, which usually is 445
What you need to do is go into SQL Server Configuration Manager where SQL Server is installed.
In the Start Menu, under the Microsoft SQL Server folder, open the Configuration Tools folder and select SQL Server Configuration Manager.
In the Config Manager, click the arrow next to SQL Server Network Configuration, then click on "Protocols for {Instance}". {Instance} will be your install, if it's the default instance it will be MSSQLSERVER.
On the right side, make sure that TCP/IP is "Enabled". Double click TCP/IP, in the window that opens, change the drop down to "Yes".
Here is the how to fix it and gain your connectivity back:
Click WindowsKey + R and enter services.msc
Once Services opens scroll down and locate service SQL Server
Highlight the service and click START
Wait for the service to start and retry to connect to your MSSQL instance
It should now work again and you will be able to connect to your MSSQL instance and run queries.
I have solved this problem. Please refer to this thread: http://social.technet.microsoft.com/Forums/forefront/en-US/d2624655-e6ff-4947-b1a8-a2edcffd8a21/denied-connection-netbios-session-protocol#68321990-4ac4-46fa-b7f8-9e0ded3234bb
In detail: I was receiving the following error from ISA when trying to connect from my SBS 2003 Server to my offsite MSSQL Database Provider via SQL Server Management Studio:
Denied Connection
Log type: Firewall service
Status: A packet generated on the local host was rejected because its source IP address is assigned to one network adapter and its destination IP address is reachable through another network adapter.
Rule:
Source: Local Host ( 192.168.1.1:29859)
Destination: External (...:139)
Protocol: NetBios Session
I have figured this out. I had to add "Local Host" as one of the sources for the ISA Rule that I had initially created to allow SQL Server Management Console connections in the first place. That rule was allowing "Internal" sources but not the Local Host (127.0.01), which is needed for this scenario.
in SSMS while opening give the server name as your_Hostname\your_sqlservername (give both the names as applicable instead of local or just only servername) it works fine.
I could ping my Virtual Machine SQL server but couldn't connect to it.
I disabled my wired and wireless NICs and then it connected !

Resources