Unable to connect to remote SQL Server database from local management studio - sql-server

I have purchased a VPS from GoDaddy. I installed SQL Server on the VPS through remote desktop connection and could connect to the database. Login credentials used are ServerName:IPAddress, Username=sa; Password=****
However when I tried to connect to the remote database from my local machine I am getting the error as
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 have cross checked the following scenarios
Made sure that TCP/IP is enabled
Made sure that SQL Server Browser is running
How can I solve this issue ?

You may have to add the IP address of your local machine to the server. Setting the IP to accessible. For security reason, it is not allowed to access the server for all the host except the host with the IP address that was added to the whitelist.
You can find the instruction in this web page.
From the web page:
If you want to connect remotely to a database, you must enable
support for remote connections.
Log in to your GoDaddy account.
Click Web Hosting.
Next to the cPanel account you want to use, click Manage.
In the Databases section, click Remote MySQL.
In the Host field, enter the IP address from where you want to access your databases.
Click Add Host.
What to enter... Host Name or Server: Your database's host
name Port: 3306 Username: The database user's username
Password: The database user's password Database: The name of the
database

Related

How to connect to Azure SQL Database through a VM jump host using DBEaver?

What I have:
Azure SQL Database on private virtual network
Jump host - Whitelisted Azure VM that can connect to the Azure SQL Database
Local machine --PuTTY--> Jump Host --sqlcmd--> Azure SQL DB
What I want to do:
Usually I PuTTY into the VM and use sqlcmd to operate, but the GUI is difficult to view when query a lot of data. So I want to use DBEaver on my local machine to access the Azure SQL Database.
Config used:
In Connection setting -> Main: Azure SQL Database (same server host, port, database, username, and password as usually used in sqlcmd)
In Connection setting -> SSH: Jump host
In Connection setting -> Main -> Edit Driver Settings -> Libraries: jdbc 9.4.1.jre8 and jdbc_auth 9.4.1.x64
Problem I face:
I tried to use ssh tunnel configuration to connect. In image 1, when I click "Test tunnel configuration", it can successfully connect to the whitelisted VM.
a) In image 2 main config, I tried to use hostname in host and click "Test connection". It failed with error message
Cannot open server "127.0.0.1" requested by the login. The login failed.
b) In image 2 main config, I changed hostname as server IP (using ping <hostname> in jump host) and retry. It failed with error message
Cannot open server "127.0.0.1" requested by the login. The login failed.
c) In image 2 main config, I tried to use random IP address in host and click "Test connection". It failed with error message
The TCP/IP connection to the host 127.0.0.1, port 45851 has failed. Error: "The driver received an unexpected pre-login response. Verify the connection properties and check that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port. This driver can be used only with SQL Server 2005 or later.".
What am I missing?
dbeaver ssh tunnel config
dbeaver main config
We have got the same issue.
Azure SQL Database needs to know the instance name associated to your username. Since you are using an ssh tunnel on 127.0.0.1, Azure can't know the name of the instance. You need to add the database name to your sql login (not the one used for the jumpbox, but the one used to connect to the db):
username#database_name.database.windows.net
Instead of
username

SQL Server authentication is not working from REMOTE

I am trying to access a SQL Server hosted on an EC2 instance from my local system. Though I am able to access it within the server using SQL Server authentication, username and password, I am not able to do the same from my local system.
The only change I am doing while accessing it from my local system is to replace the server name with its public DNS.
On the server: ServerName\SQLEXPRESS
On the local system: DNS\SQLEXPRESS,1433
I have also opened the port 1433 in the inbound rules of AWS and in windows firewall as well.
The exact error is as follows:
Login failed for user 'sa' (Microsoft SQL Server: Error 18456)
Any help/discussion to resolve this would be really appreciated.

SQL Server has lost tcp/ip connectivity, works locally

An SQL Server install on a VM was stopped incorrectly this morning. When brought back up, it communicates normally on the local machine. It no longer works on TCP/IP. Attempts to communicate with the server from SSMS on a differnt machine result in
A network-related or instance-specific error occured while establishing a
connection to SQL Server. The server was not found or is not accessible.
Very that the instance name is correct and that the SQL Server is
configured to allow remote connections. (provider:Named Pipes Provider,
error:40 - Could not open a connection to SQL Server)(Microsoft SQL Server,
Error 1326)
The user name or password is incorrect
The username and password work fine when they are used locally. Have tested Windows Auth locally, sql user remotely (we don't have a domain)
In SQL Server Configuration Manager > Sql Server Network Configuration > Protocols for MSSQLServer > TCP/IP > IP Addresses everything appears correctly configured. The IPv6 IPv4 addresses are correct, and IPAll has the correct port (default 1433)
The server can ping multiple hosts on the network. They can ping it back. It's only a single non-routeable subnet. 192.168.0.*
The name of the pc matches the name of the sql server from SELECT ##SERVERNAME
The server version is 10.50.6000 which maps to SQL Server 2008 R2
First of all 1433 Port allow in Firewall (Inbound/Outbound rule)
After then try login with
ServerName: IPAddress\InstanceName,1433
Authentication : SQL Server Authentication

“No such host” when Azure web app attempts to communicate with Azure database

Now, I have both my App Service and Database deployed in Azure, they are fine. I can browse to the site perfectly and it all seems to function.
Similarly, I've added a firewall rule in Azure to enable me to connect to the database server and query the database from my local SQL Server Management Studio.
Additionally, when I change my local web application (on my Local IIS Express server) to point to the Azure database it also works fine.
However, when I deploy the application I keep getting: "No such host is known":
[SqlException (0x80131904): 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: TCP Provider, error: 0 - No such host is
known.)] I've tried adding the IP address of the App Service to the
database server. I've even tried white listing the entire IP address
range just to completely discount that and it doesn't work either!
Any ideas?
If you're publishing from Visual Studio, make sure that you don't overwrite with a different remote connection string when deploying.
Also make sure you allow for Azure Services access.

Why can't I connect my website to a SQL Server database hosted on another computer via its public ip

I have a website hosted on a shared server, and I have setup on server to allow remote connection, and also turned on to allow remote connections.
Also I have turned the firewall off.
I am able to log in to my SQL Server via our static ip and port from a different computer not on our network from SQL Server Management Studio, and also when I run my website on my local host,
But when I publish our website to our hosted server it will not connect to our database and return an error :
[Win32Exception (0x80004005): An attempt was made to access a socket in a way forbidden by its access permissions][SqlException (0x80131904): 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: TCP Provider, error: 0 - An attempt was made to access a socket in a way forbidden by its access permissions.)]
This is our connection string
Data Source=000.000.00.00,12341;Integrated Security=False;
User ID=myUserNmae;password=myPassword;Initial Catalog=dBaseName;
What else could be wrong here?
you may have to open the program, not (simply) the port
http://technet.microsoft.com/en-us/library/cc646023.aspx
To add a program exception to the firewall using the Windows Firewall item in Control Panel.
On the Exceptions tab of the Windows Firewall item in Control Panel, click Add a program.
Browse to the location of the instance of SQL Server that you want to allow through the firewall, for example C:\Program Files\Microsoft SQL Server\MSSQL11.<instance_name>\MSSQL\Binn, select sqlservr.exe, and then click Open.
Click OK.
You'll want to read especially about "Dynamic Ports"
http://technet.microsoft.com/en-us/library/cc646023.aspx#BKMK_dynamic_ports
Can you try:
Data Source=127.0.0.1,12341;Integrated Security=False;
User ID=myUserNmae;password=myPassword;Initial Catalog=dBaseName;
Does the machine have an internal and external IP ? Aka, you may have to use the internal-IP (a real one, not just 127.0.0.1) for the IP address in the connection string.
to update you all if this issue might happen to you as well .
my website is hosted as shared hosting by hostgator and they claim that for security they will only allow traffic for sql to be done only via port 1433, which is the default port for sql...
hope this helps someone in the future

Resources