Share This!

Tuesday, June 1, 2010

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

This happened after migrating from a T1 line to a Comcast 10Mb line.   My web sites can no longer send emails because of this error. 

My setup:

I am using SBS 2003 as a web server AND as an Exchange server.  The ASP.NET code that is trying send an email looks like this:

   1:      protected void Button1_Click(object sender, EventArgs e)
   2:      {
   3:          if (IsPostBack)
   4:          {
   5:              MailMessage myMessage = new MailMessage();
   6:   
   7:              myMessage.To.Add(new MailAddress("myAddress@gmail.com", "Me"));
   8:              myMessage.Subject = Regex.Replace(Subject.Text, @"<(.|\n)*?>", string.Empty);
   9:              myMessage.ReplyTo = new MailAddress(email.Text, name.Text);
  10:              myMessage.Body = Regex.Replace(messagebody.Text, @"<(.|\n)*?>", string.Empty);
  11:   
  12:              SmtpClient MailMan = new SmtpClient("209software.com");
  13:              MailMan.EnableSsl = true;
  14:              try
  15:              {
  16:                  MailMan.Send(myMessage);
  17:              }
  18:              finally
  19:              {
  20:                  ;
  21:              }
  22:              
  23:          }



Diagnosis:
In my case, we had switched from a T1 to a 10Mb line.  everything was configured the same but we *did* get a new IP address, which we changed in the server appropriately. HOWEVER. on this new line, provided by Comcast, hitting our IP address from inside the network gets redirected to Comcast Business Gateway.  Let me demonstrate.   From the outside world, my website looks like this:


However, when I remote into my server, I see this:

Somehow the Comcast Business Gateway is intercepting hits to my IP Address from inside the network.  This causes all requests from my ASP.NET applications to email stuff using my Exchange server to go not to my server, but to this Comcast monstrosity.

The Solution:
What I did was so simple - I am embarrassed to say it took me overnight to think of it.  I logged into the webserver and added all my websites to the HOSTS file (C:\windows\system32\drivers\etc\hosts) like this:

127.0.0.1 209software.com www.209software.com mail.209software.com
Now my server can access itself when it needs to.  BTW This is a very lame approach on the part of Comcast.  I officially hate it.

No comments:

Post a Comment

Contact Us

Name

Email *

Message *