Cannot connect to local MS SQL Server

I’m having a trouble connecting to my local MS SQL server. It connects fine to my remote server, but when I try to do it for the local one, I get the following error:

“SocketException: No connection could be made because the target machine actively refused it”

Here is the code below, it fails on the last line:

string connectionString = string.Empty;
SqlConnection connection = null;

connectionString = "Data Source = DBServeName; Initial Catalog = DBName; User ID = UserName; Password = Password";

// create a connection
connection = new SqlConnection( connectionString );
// open connection
connection.Open();

Here is the screenshot:

I have tried disabling my Firewall (even though I’m connecting locally and shouldn’t matter) and checked it’s exception list, it’s all good there. I have tried to use my local IP address instead of a server name - to the same effect.

It’s something on my machine obviously as when I put IP address for the Data Source to my remote server, it works fine.

Would appreciate your help

Finally figured out. No idea why would Unity or VS2017 require TCP/IP protocol for local connection to local DB server, but that’s what it was - had to enable it under SQL Server Network Configuration and it all works now :wink: - Resolved