Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6572911
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T15:03:56+00:00 2026-05-25T15:03:56+00:00

We have a simple console app, written in C# .NET 4.0, that currently runs

  • 0

We have a simple console app, written in C# .NET 4.0, that currently runs on a scheduled task. This console app simply takes files out of one directly on disk and then uploads them to an ASP.NET web site hosted on the same machine.

When this console is run on its triggered time it fails with the following exception:

Message: Unable to connect to the remote server
Stack Trace:    at System.Net.HttpWebRequest.GetRequestStream(TransportContext& context)
   at System.Net.HttpWebRequest.GetRequestStream()
   at Program.Main(String[] args) in Program.cs:line 69
Inner Exception: System.Net.Sockets.SocketException (0x80004005): No connection could be made because the target machine actively refused it 127.0.0.1:80
   at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
   at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception)

However, when we run the application manually it runs perfectly fine as well as when we go into Scheduled Tasks and run the task manually it will execute without error.

We have the host file currently configured for the domain it is trying to connect to that points back to the loopback IP which you can see in the exception. This is in place due to a firewall configuration that doesn’t allow internal connections to the external IP.

Additional information on the Scheduled Task:

  • It is set to run under the admin credentials and with highest permissions.
  • It only runs once a day
  • It performs other operations without issue (Moving and renaming
    files)
  • The error occurs on HttpWebRequest.GetRequestStream()
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T15:03:57+00:00Added an answer on May 25, 2026 at 3:03 pm

    This ended up being a very strange situation in the end and resolving a different issue ended up being what solved this one.

    What turned out happening was there ended up being a scheduled task that was running at the exact same time that was forcing an IIS Reset. Well the IIS Reset would hit and while it was trying to start back up this process would attempt to upload a file. The upload would of course fail with the above error message because there ended up being nothing listening on port 80 while IIS service was starting.

    The Scheduled task that was being run was an old fix for a different issue around releasing resources that would be consumed by IIS. It was under a different user so it required further digging to find. Once it was disabled the daily process ran without issue.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Help me, Stackoverflow! I have a simple .NET 3.5 console app that reads some
I have a simple console app that calls a WCF service over net.tcp and
I have a fairly simple console app that monitors an exchange mailbox, picks particular
I have a simple console application written in .NET. I need to make an
I have a simple C# Console App that reads in an XML file specified
I have a small utility script written as .Net/C# console app purely for the
We have a simple console app that uses EF 4 to process data; read
This one is killing me. I'm trying to make a simple console app that
Have simple C# console app which imports text data into SQL. It takes around
I have a simple console app written in C#. I want to be able

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.