i have set up a Microsoft SQL Server 2008 R2 Express on my home computer. My home computer has Windows 7 and is behind a router. I configured it i think ok, because i can connect to him from work through management studio. Means - i opened all necessary ports, i configured SQL to accept connections on TCP. I have also on my router set up DynDNS and i connect through my DNS name and it works.
I use also Microsoft PortQueryUI [ http://www.microsoft.com/download/en/details.aspx?id=24009 ] to test if the server is visible and from my work computer and it is visible. My PortQueryUI output at work is ok (attached bloew) but people from other networks cannot connect to my server.They have in the test to port 1434 UDP (big bold) an error code 0x00000002 where i have it correct - 0x00000000.
What is the reason, is there something that needs to be done on their computers? Maybe their network is blocking something?
My PortQueryUI output from work:
=============================================
Starting portqry.exe -n myhome.dyndns.net -e 1434 -p UDP ...
Querying target system called:
myhome.dyndns.net
Attempting to resolve name to IP address...
Name resolved to 83.xxx.xxx.xxx
querying...
UDP port 1434 (ms-sql-m service): LISTENING or FILTERED
Sending SQL Server query to UDP port 1434...
Server's response:
ServerName ROBERT-KOMPUTER
InstanceName SQL2008R2
IsClustered No
Version 10.50.1600.1
tcp 1433
np \\ROBERT-KOMPUTER\pipe\MSSQL$SQL2008R2\sql\query
==== End of SQL Server query response ====
UDP port 1434 is LISTENING
portqry.exe -n myhome.dyndns.net -e 1434 -p UDP exits with return code 0x00000000.
=============================================
Starting portqry.exe -n myhome.dyndns.net -e 1433 -p TCP ...
Querying target system called:
myhome.dyndns.net
Attempting to resolve name to IP address...
Name resolved to 83.xxx.xxx.xxx
querying...
TCP port 1433 (ms-sql-s service): LISTENING
portqry.exe -n myhome.dyndns.net -e 1433 -p TCP exits with return code 0x00000000.
Make sure port 1433 is open on your firewall where SQL is, you should probably put some sort of IP range/scope on that too for security.
You need to set your database to Accept Remote Connections in the DB properties.
You need to setup a username and password and give it access to the database so your remote connection recognizes it.
Here's an example of allowing the connection:
http://blogs.msdn.com/b/walzenbach/archive/2010/04/14/how-to-enable-remote-connections-in-sql-server-2008.aspx
Here's an example of connecting:
http://www.youtube.com/watch?v=hT9p_FPt720
I had the same problem but I had already setup open ports on 1433 on the firewall. The solution for me was simple on SQL 2012:
Goto "Sql Server Connection Manager"
Drop down SQL server network configuration
Protocols for MSSQLSERVER > Right click TCIP/IP
on every "TCP Port" entered 1433 or whatever port you wish
done
I have a non-default named instance. So I`ve had to enable and start the SQL Server Browser service on services.msc
Make sure to check Microsoft's troubleshooting below:
https://learn.microsoft.com/en-us/archive/blogs/sql_protocols/steps-to-troubleshoot-sql-connectivity-issues
Related
i am trying to connect to a PostgreSQL DB which is hosted on Windows 10 machine.
I have changed the following settings on ini file:
listen_addresses = '*' is set in postgresql.conf
host all all 0.0.0.0/0 md5 is set pg_hba.conf
I have enabled the 5432 port for TCP/IP connections and I have checked that it is listening.
Results:
IT WORKS when I try to connect to the DB from a machine that is under the same network as the machine hosting the server using the private IP for connection
IT DOES NOT WORK when I try to connect to the DB from a machine outside the network of the machine hosting the server, using the public IP for connection
I have seen several topics about it, but the only suggestions are to modify init file and add a rule to open TCP/IP on 5432 port.
Could you please help?
thanks!
We cannot access from a client computer (Client) to a SQL Server computer (Server) on network A but successfully on another B. The Server computer has SQL Server 2019 installed, the Client computer has SQL Native Client 11.0 installed. We can connect from this client to the server in on network A either using sqlcmd, udl interface, or Telnet. But on a different network B, we cannot connect from the same Client to the same Server! What network configuration can avoid a SQL Server connection?
Server Parameters:
1. We defined firewall rules to allow inbound connection on ports 1433 for TCP and 1434 for UDP. We verified that that is the case on the Server by using "netstat -aon". We disabled the Norton Smart Firewall.
2. We have set this rule to apply to all profiles: Domain, Public, Private.
3. We ensured that all protocols for SQLEXPRESS are allowed and enabld in the SQL Server Configuration Manager, specifically TCP/IP.
4. We have enabled SQL Server Browser.
5. We have restarted all services multiple times after our configuration changes. We have even restarted the machine.
6. We made sure that the Server is accessible remotely and using SQL Server Authentication.
7. We reset both the modem and the router for both Networks before testing.
8. We confirmed both the Computer and the SQL Instance names in the SMSS logins and logs.
Tests we did on Network A:
1. We can ping the Client from the Server, the Server from the Client both with IP addresses and computer names (On Server: "ping -a ClientIP/ComputerName", On Client: "ping -a ServerIP/ComputerName". Both results with "Reply...").
2. We can access the database in the Server using SSMS both with Windows Authentication and SQL Server Authentication.
3. We cannot access to Server from the Client by Windows Authentication either by using "sqlcmd -S Server\sqlexpress -E".
4. We cannot access to Server from the Client by SQL Server Authentication by using "sqlcmd -U User -P Password -S Server\SQLExpress".
On the other hand, when these computers are in Network B, without changing anything we can connect to Server from the Client.
Here are the error messages we get:
sqlcmd -U User -P Password -S Server\SQLExpress
By default named instances use dynamic ports, which you're not allowing through the firewall.
The best solution is probably to simply configure the SQL Server instance to listen on the fixed port 1433, then you don't need to use an Instance Name or explicit port to connect.
To do this us SQL Server Configuration Manager to configure the instance to listen on port 1433 on all IPs. It should look like this:
With Dynamic Ports blank, and 1433 in the TCP IP port.
Then restart the SQL Server instance and in the SQL Server Logs you should see a message like
Server is listening on [ 'any' <ipv4> 1433].
Then try to connect like
sqlcmd -U User -P Password -S Server
And you can test with Powershell
PS C:\> test-netconnection Server -port 1433
If you do this you won't need the SQL Browser Service or the firewall rule for port 1434.
I have Microsoft SQL Server 2014 Express running on my local machine, a Windows 7 PC.
I use Python and can connect to the server (from the very same PC) without any problems, using SQL alchemy. I can also connect using Excel and the PowerPivot add-in.
However, I cannot connect with Pentaho - Kettle.
I have downloaded the JDBC driver from Microsoft:
https://www.microsoft.com/en-gb/download/details.aspx?id=11774
I took the file jre8\sqljdbc42.jar and moved it to the lib subfolder of
the Pentaho Data Integration installation. I took the file in jre8, not jre7, because my Java is JRE1.8.0_144
I then took the file in auth\x86\sqljdbc_auth.dll and copied it to the same lib folder. I took the x86 file, not the x64, because Java is in c:\Program Files (x86)\Java\jre1.8.0_144\
I add 'table input' and set connection type= MS SQL Server (native) and Access = Native (JDBC)
The error message I get is:
Error connecting to database [mydatabase] :org.pentaho.di.core.exception.KettleDatabaseException: Error occurred while trying to connect to the database
Error connecting to database: (using class com.microsoft.sqlserver.jdbc.SQLServerDriver) The TCP/IP connection to the host localhost, port 1433 has failed. Error: "Connection refused: connect. Verify the connection properties. Make sure that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port. Make sure that TCP connections to the port are not blocked by a firewall.".
org.pentaho.di.core.exception.KettleDatabaseException: Error occurred while trying to connect to the database
Error connecting to database: (using class com.microsoft.sqlserver.jdbc.SQLServerDriver) The TCP/IP connection to the host localhost, port 1433 has failed. Error: "Connection refused: connect. Verify the connection properties. Make sure that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port. Make sure that TCP connections to the port are not blocked by a firewall.".
I have tried various combinations of specifying port number 1433 and of leaving it blank, of using integrated security and of entering my password manually, of setting host name to localhost and to DESKTOP-MYNAME\SQLEXPRESS, but to no avail.
I have read lots of discussions about it but none seems relevant; the SQL Server does accept incoming connections, e.g. from Python and SQL Alchemy.
I ran the SQL Server 2014 configuration manager, and checked:
SQL Server network configuration --> Protocols for SQLEXPRESS --> TCP/IP
In the protocol tab, I had: enabled: yes and Listen All: Yes
In the "IP Addresses" tab, under IPAll at the bottom, "TCP Dynamic ports" was set to 49178. (No idea why).
So I set the port in the 'table input' setup of Pentaho to 49178. It managed to find the server, but there was an error about integrated security. So I copied sqljdbc_auth.dll to both the bin and the lib subfolders of C:\Program Files (x86)\Java\jre1.8.0_144 .... and now it works!
If I don't specify the port, Pentaho tries port 1433, and it doesn't work.
For reference, the connection string I use with Python and SQL Alchemy does not specify the port explicitly.
params = '?driver=SQL+Server+Native+Client+11.0'
engine = create_engine('mssql+pyodbc://' + ServerName + '/'+ Database + params, encoding ='latin1' )
conn=engine.connect()
SQL Server network configuration --> Protocols for SQLEXPRESS --> TCP/IP
In the protocol tab, I had: enabled: yes and Listen All: Yes
In the "IP Addresses" tab, under IPAll at the bottom, "TCP Dynamic ports" was set to 49178.
So I set the port in the 'table input' setup of Pentaho to 49717.
this worked for me also..
I have to connect to a fresh SQL Server Express 2017 on a machine not part of my domain. I have configured
Mixed Mode Installation with sa with password
SSMS -> Server -> Properties -> Connections -> Allow remote connections
SQL Configuration Manager -> Instance "EXPRESS2017" -> TCP/IP: Enable and Active and Port 1438
Restarted the "SQL Server (EXPRESS2017)" service.
I now tried to access from a remote computer, and got a timeout. I then tried to connect from the local SSMS, which works without special settings, but when under options, forced "Protocol: TCP/IP" is set, with the same credentials as before, I also got a timeout.
So am I right that I can rule out the firewall or problems finding the instance, and everything points towards a configuration issue in TCP/IP protocol, or did I overlook some setting?
EDIT: I have disabled Windows firewall, and no other firewall is installed on the computer. I have restarted the computer. I also found this article about PortQry and had a check - locally:
C:\Users\Administrator\Downloads>PortQry.exe -n 172.17.41.124 -p UDP -e 1434
Querying target system called:
172.17.41.124
Attempting to resolve IP address to a name...
IP address resolved to WIN-AECL8CJVS7E.test.local
querying...
UDP port 1434 (ms-sql-m service): NOT LISTENING
EDIT: I have run NETSTAT and it seems no port in the 14xx range is open at all, although the SQL Server Browser service is running. I must be missing something there...
You did not show your connection string, but I suppose you use your instance name here.
In order to connect to SQL Server the network library has to know 2 things: IP address and a port. Your instance is named and uses non-default port 1438.
So your connection string should use 172.17.41.124,1438 as server name, or, alternatively, you can use instance name like this: 172.17.41.124\EXPRESS2017 but SQL Server Browser should run.
I've just installed a fresh copy of SQL 2008 Express. before I did anything I opened Management Studio and successfully connected using Window Authentication.
However I tried to run the following on the command line
"telnet localhost 1433" and got the error "Could not open connection to the host, on port 1433: Connect failed"
I checked netstat and there is nothing listening on port 1433.
Before I go any further, is there a problem with the install?
thanks,
Shane
did you check if the tcp/ip protocol is enabled? It's disabled by default if I remember correctly.
are you telling your SQL Server to listen on TCP/IP
http://blogs.msdn.com/sqlexpress/archive/2005/05/05/415084.aspx
The port number isn't guaranteed to be 1433.
In Sql Server Configuration Manager, make sure:
(1) SQL Server is running
(2) SQL Server Browser is running.
(3) In the Protocols for SQLEXPRESS that TCP/IP is on. You can check the port inside there.
Alternately get the port by finding the PID of sqlservr.exe in Task Manager and then typing:
netstat -ano | findstr PID
Prior to these steps I couldn't connect via 127.0.0.1 myself, now I can connect even from a remote machine on my LAN. (Note: for LAN access you'll need to add firewall exceptions for sqlservr.exe and sqlbrowser.exe)