It sounds like a proxy server (I suspect MS ISA) authentication problem on the dev machine:
Code running in a console application in development: fine because the application is running in the context of a user account (you) that has the correct security context to make a request through the proxy server.
Code running in an ASP.NET web application in development: doesn't work because the application is running under a system account (NETWORK SERVICE, LOCAL SYSTEM whatever) and the proxy server refuses to serve the request for that user.
Code running in an ASP.NET web application in the live environment: might sometimes just work without any impersonation / changes from the dev code that didn't previously work and this can be confusing. It depends on the environment setup because sometimes live servers are positioned where they don't make requests through a proxy that requires authentication.
I seem to remember this exception containing an IP address that tells you specifically which 'target machine' refused the connection.
Code based impersonation / user context switching is a solution I've used in the past for this problem: e.g. switch to a user account (usually a real windows domain user account specifically created for this purpose i.e. a service account with a password that never expires) that can definitely burrow through the proxy server when making an outbound HttpWebRequest and undo impersonation immediately afterwards. Doing it this way meant the code worked in all environments regardless of infrastructure configuration.
- Visitors can check out the Forum FAQ by clicking this link. You have to register before you can post: click the REGISTER link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. View our Forum Privacy Policy.
- Want to receive the latest contracting news and advice straight to your inbox? Sign up to the ContractorUK newsletter here. Every sign up will also be entered into a draw to WIN £100 Amazon vouchers!
Collapse
You are not logged in or you do not have permission to access this page. This could be due to one of several reasons:
- You are not logged in. If you are already registered, fill in the form below to log in, or follow the "Sign Up" link to register a new account.
- You may not have sufficient privileges to access this page. Are you trying to edit someone else's post, access administrative features or some other privileged system?
- If you are trying to post, the administrator may have disabled your account, or it may be awaiting activation.
Logging in...
Previously on "No connection could be made because the target machine actively refused it"
Collapse
-
No I did not try that, but will do so and see if that has any affect. Thanks.Originally posted by biondani View PostHave you tried disableloopbackcheck and disablestrictnamechecking in the registry?
Ian
Leave a comment:
-
Have you tried disableloopbackcheck and disablestrictnamechecking in the registry?
Ian
Leave a comment:
-
I have just published the web page on a proper website and tested it and it works. The same code fails using localhost.Originally posted by Durbs View PostEdited, i'd had this before and was trying to think how it was resolved, as i remember, it was caused by the corporate firewall settings on our client machines blocking the call. Worked ok once we uploaded to the dev box that had no such rules applied. Your case sounds different though if other sites on the same box are responding. Do the IIS logs on the box shed any more light?
Even more weird is the fact that requests to some websites work and some do not. You are right that it could be firewall but it could be a combination of firewall and something else.
I might just leave it at that and wont bother testing on my local machine.
Leave a comment:
-
Edited, i'd had this before and was trying to think how it was resolved, as i remember, it was caused by the corporate firewall settings on our client machines blocking the call. Worked ok once we uploaded to the dev box that had no such rules applied. Your case sounds different though if other sites on the same box are responding. Do the IIS logs on the box shed any more light?Originally posted by Durbs View PostHave you tried using impersonation? Or is it just running as the standard local network service account?
Leave a comment:
-
Have you tried using impersonation? Or is it just running as the standard local network service account?
Leave a comment:
-
No connection could be made because the target machine actively refused it
Hi Chaps
I normally do not post asking for a solution but this one has really driven me mad.
I am using the HttpWebRequest object in the .NET framework to perform a really normal 'GET' request. The target is on IIS.
If I run the code through a console application it runs fine and I get a response back.
If I run it through a web app ( ASP.NET, C#) I get the above exception.
Two days of googling and troubleshooting has got me nowhere.
Another thing is, on that same IIS box, there are two more websites which return a response, but the rest give me that exception.
Any clues? Anybody encountered this problem before ?Tags: None
- Home
- News & Features
- First Timers
- IR35 / S660 / BN66
- Employee Benefit Trusts
- Agency Workers Regulations
- MSC Legislation
- Limited Companies
- Dividends
- Umbrella Company
- VAT / Flat Rate VAT
- Job News & Guides
- Money News & Guides
- Guide to Contracts
- Successful Contracting
- Contracting Overseas
- Contractor Calculators
- MVL
- Contractor Expenses
Advertisers
Contractor Services
CUK News
- Statutory Sick Pay (SSP) for umbrella company contractors: an April 2026 explainer Yesterday 07:19
- IR35: IT contractors ‘most concerned about off-payroll working rules’ Feb 4 07:11
- Labour’s near-silence on its employment status shakeup is telling, and disappointing Feb 3 07:47
- Business expenses: What IT contractors can and cannot claim from HMRC Jan 30 08:44
- April’s umbrella PAYE risk: how contractors’ end-clients are prepping Jan 29 05:45
- How EV tax changes of 2025-2028 add up for contractor limited company directors Jan 28 08:11
- Under the terms he was shackled by, Ray McCann’s Loan Charge Review probably is a fair resolution Jan 27 08:41
- Contractors, a £25million crackdown on rogue company directors is coming Jan 26 05:02
- How to run a contractor limited company — efficiently. Part one: software Jan 22 23:31
- Forget February as an MSC contractor seeking clarity, and maybe forget fairness altogether Jan 22 19:57

Leave a comment: