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

后端 未结 28 2044
北荒
北荒 2020-11-22 01:27

Sometimes I get the following error while I was doing HttpWebRequest to a WebService. I copied my code below too.


System.Net.WebException: Unable to connect         


        
相关标签:
28条回答
  • 2020-11-22 01:49

    Using WampServer 64bit on Windows 7 Home Premium 64bit I encountered this exact problem. After hours and hours of experimentation it became apparent that all that was needed was in my.ini to comment out one line. Then it worked fine.

    commented out 1 line socket=mysql

    If you put your old /data/ files in the appropriate location, WampServer will accept all of them except for the /mysql/ folder which it over writes. So then I simply imported a backup of the /mysql/ user data from my prior development environment and ran FLUSH PRIVILEGES in a phpMyAdmin SQL window. Works great. Something must be wrong because things shouldn't be this easy.

    0 讨论(0)
  • 2020-11-22 01:50

    In my case, some domains worked, while some did not. Adding a reference to my organization's proxy Url in my web.config fixed the issue.

    <system.net>
        <defaultProxy useDefaultCredentials="true">
          <proxy proxyaddress="http://proxy.my-org.com/" usesystemdefault="True"/>
        </defaultProxy>
    </system.net>
    
    0 讨论(0)
  • 2020-11-22 01:50

    In my scenario, I have two applications:

    • App1
    • App2

    Assumption: App1 should listen to App2's activities on Port 5000

    Error: Starting App1 and trying to listen, to a nonexistent ghost town, produces the error

    Solution: Start App2 first, then try to listen using App1

    0 讨论(0)
  • 2020-11-22 01:50

    In my case this was caused by a faulty deployment where a setting in my web.config was not made.

    A collegue explained that the IP address in the error message represents the localhost.

    When I corrected the web.config I was then using the correct url to make the server calls and it worked.

    I thought I would post this in case it might help someone.

    0 讨论(0)
  • 2020-11-22 01:51

    I faced same error because when your Server and Client run on same machine the Client need server local ip address not Public ip address to communicate with server you need Public ip address only in case when Server and Client run on separate machine so use Local ip address in client program to connect with server Local ip address can be found using this method.

     public static string Getlocalip()
        {
            try
            {
                IPAddress[] localIPs = Dns.GetHostAddresses(Dns.GetHostName());
                return localIPs[7].ToString();
            }
            catch (Exception)
            {
    
                return "null";
            }
    
        }
    
    0 讨论(0)
  • 2020-11-22 01:51

    I just faced this right now...

    Here on my end, I have 2 separated Visual Studio solutions (.sln)... opened each one in their own Visual Studio instance.

    Solution 2 calls Solution 1 code. The problem was related to the port assigned to Solution 1. I had to change the port on solution 1 to another one and then Solution 2 started working again. So make sure you check the port assigned to your project.

    0 讨论(0)
提交回复
热议问题