I'm trying to connect to an SQLEXPRESS database on an Azure VM(classic). My local machine is a Mac with sql-cli installed.
I have created a user within SQL Management Studio that is set to SQL Server authentication. I can connect with the credentials using SQL Management Studio on the server.
I have opened TCP 1433 in Windows (Server 2012) Firewall. I have added an endpoint in Azure for port 1433.
TCP/IP is enabled within SQL Server Configuration Manager.
I'm connecting with:
mssql -s [IP address] -u [user] -p [password] -d [database]
And I get the following message:
Error: Failed to connect to [Ip address]:1433 in 15000ms
What else can I check?
Related
I need to access a SQL Server database which is installed on one machine and I want to access it from another machine. I have tried below options and nothing work
I have enabled TCP\IP with IPALL as 1433 in SQL Server Configuration manager
SQL Server and SQL Server Browser services are running, restarted after modified the configuration
Added SQL Server and TCP port to Windows firewall (allowed apps) as domain and public
Used
sqlcmd -S servername,portname -U username -P password -d database
What am I missing? On my local machine, it is working
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 created an Amazon RDS database in SQL Server, created a custom security group with inbound rule type SQL Server protocal TCP Port "XXXX" Source "My PC's IP Address/32", allowed port "XXXX" over my firewall via "sudo ufw allow from any to any port "XXXX" proto tcp", successfully installed SQL Server on ubuntu via this tutorial: https://computingforgeeks.com/how-to-install-ms-sql-on-ubuntu/, and set 'public-accessibility' to 'no' in my AWS Database.
However, when I try to log in to my AWS Database from the command line via:
sqlcmd -S databasename.code.us-east-#.rds.amazonaws.com,XXXX -U username -P password -d DatabaseName
I get the error:
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : TCP Provider: Error code 0x102.
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online..
I spelled everything correctly. What am I doing wrong?
Can you please check your network ACL's of your VPC and also make sure you have ephemeral ports allowed on your VPC ACL's.
https://docs.aws.amazon.com/vpc/latest/userguide/vpc-network-acls.html#nacl-ephemeral-ports
I am using SSMS to connect to a SQL Server 2012 database that resides on my Godaddy VPS. I'm unable to connect from SSMS, but I can connect normally from inside the domain.
I have opened port 1433 for TCP connections through RDP (IPAll). I have restarted SQL Server also. But am not sure whether my Windows Server machine allows inbound connection to 1433.
On SSMS login I am using
server name as ip-address:1433
authentication as SQL Server authentication
followed by username, password
But I'm unable to connect.
Getting a message "login failed for user [my_user]"
Of note is that I am capable of connecting to the server with freetds from linux using the same server, username and password and TDS protocol 7.4. The port is the default SQL Server port. Viz. $tsql -S [my_server] -U "my_user" -P "my_pass" succeeds and I am able to poke around in the server.
However, on my windows machine, it simply reports that my login has failed.
Data Source: Microsoft SQL Server
Server Name: [my_server]
Use SQL Server Authentication: User name: [my_user] Password: [my_pass]
Any thoughts on what to try?
UPDATE:
I can connect via pymssql with
pymssql.connect(server=[my_server], user=[my_user], password=[my_pass])