I am working on a group sourced project that requires a SQL database that we all need to connect to remotely. We don't have a common domain or VPN to connect to one so I read creating a SQL Server Authentication and TCP port could circumvent that.
I have setup the server and database directly on my laptop and followed the Microsoft documentation to create a TCP Fixed Port and created the corresponding rule in my firewall.
I then created the login and permissions for the SQL Server Authentication.
I tested the login on my laptop (where the server is hosted) and on my PC desktop (a totally different computer) and it worked just fine.
However, when my team members tried to access it from their remote locations I get the following error
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 assume this is because they don't share my IP/domain on my home internet as my desktop and laptop do.
Is there any way to connect to a SQL database remotely without being on the same domain?
CodePudding user response:
I assume this is because they don't share my IP/domain on my home internet as my desktop and laptop do.
Correct. Your home network is behind a firewall and hosts on the internet are not allowed to connect.
For limited dev purposes you could use a tunneling solution like ngrok
After you sign up and download, assuming your SQL Server is on port 1433, run
PS C:\utils> .\ngrok tcp 1433
which will inform you of the tunnel details:
ngrok by @inconshreveable
(Ctrl C to quit)
Session Status online
Account David Browne (Plan: Free)
Version 2.3.40
Region United States (us)
Web Interface http://127.0.0.1:4040
Forwarding tcp://4.tcp.ngrok.io:17247 -> localhost:1433
Connections ttl opn rt1 rt5 p50
p90
0 0 0.00 0.00 0.00 0.00
Which tells you to use tcp:4.tcp.ngrok.io,17247
in your connection string.
Or you could move to a database hosted and accessable on the internet, like Azure SQL Database.