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

Problem is:

Server Error in ‘/’ Application.

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

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it

Stack Trace:

[SocketException (0x274d): No connection could be made because the target machine actively refused it]
   System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) +251
   System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception) +279

[WebException: Unable to connect to the remote server]
   System.Net.HttpWebRequest.GetRequestStream(TransportContext& context) +6100429
   System.Net.HttpWebRequest.GetRequestStream() +13
   System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters) +110
   WebServices in xxx\Reference.cs:331
   UserControls_xxx.gv_RowDataBound(Object sender, GridViewRowEventArgs e) in xxx.ascx.cs:835
   System.Web.UI.WebControls.GridView.OnRowDataBound(GridViewRowEventArgs e) +115
   System.Web.UI.WebControls.GridView.CreateRow(Int32 rowIndex, Int32 dataSourceIndex, DataControlRowType rowType, DataControlRowState rowState, Boolean dataBind, Object dataItem, DataControlField[] fields, TableRowCollection rows, PagedDataSource pagedDataSource) +181
   System.Web.UI.WebControls.GridView.CreateChildControls(IEnumerable dataSource, Boolean dataBinding) +3896
   System.Web.UI.WebControls.CompositeDataBoundControl.PerformDataBinding(IEnumerable data) +66
   System.Web.UI.WebControls.GridView.PerformDataBinding(IEnumerable data) +14
   System.Web.UI.WebControls.DataBoundControl.OnDataSourceViewSelectCallback(IEnumerable data) +128
   System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) +33
   System.Web.UI.WebControls.DataBoundControl.PerformSelect() +143
   System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +74
   System.Web.UI.WebControls.GridView.DataBind() +4
   System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
   System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
   System.Web.UI.Control.OnLoad(EventArgs e) +91
   System.Web.UI.Control.LoadRecursive() +74
   System.Web.UI.Control.LoadRecursive() +146
   System.Web.UI.Control.LoadRecursive() +146
   System.Web.UI.Control.LoadRecursive() +146
   System.Web.UI.Control.LoadRecursive() +146
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2207


Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.272

My solution and my story(solved):

I’ve been looking for solution from many article, but there is no solution according to my problem. They said because of proxy, I don’t use proxy, just local development. Come on… my previous project run well, but when I copied project solution from my office local dev and run it in my local dev, this is the problem. I have been stuck for considerable time, but I must finish my work. I can debug it.

Finally, after try and try, check all of setting and the solution very simple. Oh ya… this is happen in my web service solution. I have two web service, I see in web.config, both of it use different port, but because it in one project, ideally it uses the same port. I change it and make same port. I rebuild and succeeded, but when run in web, No connection could be made because the target machine actively refused it, I think I have changed the port to 63600 in web config and also web service url, but why port 63601 still be used. This is a mistery for me, like a ghost. Hehehe.

Oh no, come on… don’t be a stupid thinking guys (for me) and I happy to find the solution by myself. Just go to your project, expand and see Properties -> Settings.settings. Double click and change the value. This solve my days.

No connection could be made

BPN 301113 place of exile for a while