Q:

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

I have extracted the following code from selenium IDE.(c# remote control)
using System;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using NUnit.Framework;
using Selenium;

namespace SeleniumTests
{
[TestFixture]
public class MyFirstVCTest
{
    private ISelenium selenium;
    private StringBuilder verificationErrors;

    [Test]
    public void TheNewTest()
    {
        selenium.Open("/");
    } 

    [SetUp]
    public void SetupTest()
    {
        selenium = new DefaultSelenium("localhost", 4444, "*chrome","http://demo.volunteercampaigns.com/");
        selenium.Start();
        verificationErrors = new StringBuilder();
    }

    [TearDown]
    public void TeardownTest()
    {
        try
        {
            selenium.Stop();
        }
        catch (Exception)
        {
            // Ignore errors if unable to close the browser
        }
        Assert.AreEqual("", verificationErrors.ToString());
    }

    [Test]
    public void TheMyFirstVCTest()
    {
        selenium.Open("/?AspxAutoDetectCookieSupport=1");
        selenium.Click("link=Login");
        selenium.WaitForPageToLoad("30000");
        selenium.Type("id=ctl00_ContentPlaceHolder1_txtEmailAddress", "elonadminss@eeeorbees.com");
        selenium.Type("id=ctl00_ContentPlaceHolder1_txtPassword", "orbs123");
        selenium.Click("id=ctl00_ContentPlaceHolder1_btnlogin");
        selenium.WaitForPageToLoad("30000");
        selenium.Click("id=ctl00_lblUserName");
        selenium.Click("id=ctl00_lnkSignOut");
        selenium.WaitForPageToLoad("30000");
    }
}
}

i created a webform and added a button there.
in button click event i wrote this code
SeleniumTests.MyFirstVCTest m = new SeleniumTests.MyFirstVCTest();
    m.SetupTest();
    m.TheMyFirstVCTest();
    m.TeardownTest();

i included all .dll files. its running fine(no errors and warnings).
but after clicking button i am getting the following error
No connection could be made because the target machine actively refused it 127.0.0.1:4444

what should i do??
thanks in advance..
Note to viewers: This post may help you : No connection could be made because the target machine actively refused it

A:

"...the target machine actively refused it" means the server could be reached and responded within the timeout, but the specified port wasn't open. This can have several reasons, e.g. a local firewall blocking the connection. Are you sure the server is listening on the right IP/port?

A:

To add more clarity for the readers: Start selenium server using the followings basic steps:

Download selenium -server standalone from official selenium download
page.

Open command prompt. 
Navigate to the folder using "Cd ".  
Add this command: "java - jar ".
Hit enter.
Selenium server will be started.

A:

I get the same error, but on a different line of code. Hopefully this might help someone somewhere even if it doesn't answer the initial question.
    public override void SetupTest()
    {
        Driver = new FirefoxDriver();
        base.SetupTest();
    }

I'm using the WebDriver (I don't run the Selenium server), and the constructor of FirefoxDriver throws the Exception.
Sometimes I get this exception:
A first chance exception of type 'System.Net.Sockets.SocketException' occurred in System.dll
Additional information: No connection could be made because the target machine actively refused it

with this call stack:
    WebDriver.dll!OpenQA.Selenium.Firefox.Internal.ExtensionConnection.ConnectToBrowser(System.TimeSpan timeToWait) Line 247    C#
    WebDriver.dll!OpenQA.Selenium.Firefox.Internal.ExtensionConnection.Start() Line 98  C#
    WebDriver.dll!OpenQA.Selenium.Firefox.FirefoxDriver.StartClient() Line 237  C#
    WebDriver.dll!OpenQA.Selenium.Remote.RemoteWebDriver.RemoteWebDriver(OpenQA.Selenium.Remote.ICommandExecutor commandExecutor, OpenQA.Selenium.ICapabilities desiredCapabilities) Line 89    C#
    WebDriver.dll!OpenQA.Selenium.Firefox.FirefoxDriver.FirefoxDriver(OpenQA.Selenium.Firefox.FirefoxBinary binary, OpenQA.Selenium.Firefox.FirefoxProfile profile, OpenQA.Selenium.ICapabilities capabilities, System.TimeSpan commandTimeout) Line 172    C#
    WebDriver.dll!OpenQA.Selenium.Firefox.FirefoxDriver.FirefoxDriver(OpenQA.Selenium.Firefox.FirefoxBinary binary, OpenQA.Selenium.Firefox.FirefoxProfile profile, System.TimeSpan commandTimeout) Line 167    C#
    WebDriver.dll!OpenQA.Selenium.Firefox.FirefoxDriver.FirefoxDriver(OpenQA.Selenium.Firefox.FirefoxBinary binary, OpenQA.Selenium.Firefox.FirefoxProfile profile) Line 154    C#
    WebDriver.dll!OpenQA.Selenium.Firefox.FirefoxDriver.FirefoxDriver(OpenQA.Selenium.Firefox.FirefoxProfile profile) Line 132  C#
    SetupTest() Line 513    C#

Sometimes I get this exception: 
A first chance exception of type 'System.Net.Sockets.SocketException' occurred in System.dll
Additional information: Only one usage of each socket address (protocol/network address/port) is normally permitted

with this call stack:
    WebDriver.dll!OpenQA.Selenium.Firefox.Internal.ExtensionConnection.DetermineNextFreePort(string host, int port) Line 161    C#
    WebDriver.dll!OpenQA.Selenium.Firefox.Internal.ExtensionConnection.Start() Line 88  C#
    [same as above]

But one thing I didn't realize at first is that if you continue execution (F5), everything is fine. The Exception must be handled in the WebDriver.
The only thing is that I had the DEBUG/Exceptions/CLR Exceptions: Thrown [checked].
Just uncheck that and everything runs without throwing/breaking. Took me a while to realize that. Leftovers of a previous debugging session...

