Connecting to server which located remotely throws timeout exception Below are the steps which I follow while connecting manually:


Connect to VPN
RDP to the remote machine using my credentials
Open SQL Server Management Studio
Connect to Server > database engine, Server Name > "Name", Authentication >  Windows Authentication
Run query


And the connection string that I am using is: 

ConnectionString = "Data Source =tcp:&lt;IPAddress of RDP Machine&gt;\&lt;ServerName&gt;;
Initial Catalog =&lt;DBName&gt;; User Id = &lt;Username&gt;; 
Password = &lt;Password&gt;; Trusted_Connection = True; 
Integrated Security = SSPI; Connect Timeout = 30; Encrypt = False; TrustServerCertificate = False"
In your manual procedure you state that you specify "name" in the server name, not an instance.

However in your connection string you specify

Data Source =tcp:&lt;IPAddress of RDP Machine&gt;\&lt;ServerName&gt;;


Which indicates &lt;servername&gt; should be used as an instance name.

You should probably remove \&lt;servername&gt; part of your connection string.

You should also verify the necessary ports are open on the firewall and make sure SQL Server is configured to allow remote connections as well as make sure tcp/ip is in the enabled protocols.

There is a decent MSDN blog post covering a lot of other steps you can take to troubleshoot your connectivity issues: Troubleshoot Connectivity/Login failures (18456 State x) with SQL Server