Reader Level:
Articles

No connection could be made because the target machine actively refused it

By Mahesh Chand on April 26, 2012
Fix for error no connection could be made because the target machine actively refused it.
  • 0
  • 0
  • 17550

No connection could be made because the target machine actively refused it

You may get this error while trying to establish a connection to a SQL Server database remotely. Here are a few things you should check.

  • Make sure your server name is correct.
  • Make sure database server is up and running. You can see MSSQLSERVER service or whatever is your SQL Server instance name is running.
  • Try to ping your server name and see if IP is correct.
  • Ping the IP address and see it is resolving.
  • If your server is behind firewall, you may want to add a port number to your connection string. Port 1433 is the default port for SQL Server.

By default, SQL Server uses port number 1433. To create a connection string over firewall with the IP and port number, use the following format:

<add name="connection" connectionString="Data Source=[YOURIP XX.XX.XX.XX],1433;Network Library=DBMSSOCN;Initial Catalog=[YOURDBNAME];User ID=[YOURUSERID];Password=[YOURPASSWORD]"/>

You need to make sure you replace variables in this connection string with correct values.

 

Mahesh Chand

Mahesh Chand is founder of C# Corner. C# Corner founded in 1999 is a FREE member contributions based open platform for developers to solve problems, learn new technology and hang out.  Mahesh has been awar... Read more

COMMENT USING

Trending up