title: 404 Errors on WCF service hosted in Windows Service
body: <p>I am trying to create a WCF service hostsed in windows service and I'm testing locally before I deploy to a server.</p>
  
  <p>Created and installed the service ok and I can run the service just fine.</p>
  
  <p>When I try to add a reference either though Visual studio or using WCFTestClient I get the following error.</p>
  
  <blockquote>
    <p>Error: Cannot obtain Metadata from
    <a href="http://localhost/ServiceModelSamples/service" rel="nofollow">http://localhost/ServiceModelSamples/service</a> If this is a Windows (R)
    Communication Foundation service to which you have access, please
    check that you have enabled metadata publishing at the specified
    address.  For help enabling metadata publishing, please refer to the
    MSDN documentation at
    <a href="http://go.microsoft.com/fwlink/?LinkId=65455.WS-Metadata" rel="nofollow">http://go.microsoft.com/fwlink/?LinkId=65455.WS-Metadata</a> Exchange
    Error URI: <a href="http://localhost/ServiceModelSamples/service" rel="nofollow">http://localhost/ServiceModelSamples/service</a>     Metadata
    contains a reference that cannot be resolved:'
    <a href="http://localhost/ServiceModelSamples/service" rel="nofollow">http://localhost/ServiceModelSamples/service</a>'. There was no endpoint
    listening at <a href="http://localhost/ServiceModelSamples/service" rel="nofollow">http://localhost/ServiceModelSamples/service</a> that could
    accept the message. This is often caused by an incorrect address or
    SOAP action. See InnerException, if present, for more details.     The
    remote server returned an error: (404) Not Found. HTTP GET Error<br>
    URI: <a href="http://localhost/ServiceModelSamples/service" rel="nofollow">http://localhost/ServiceModelSamples/service</a>    There was an
    error downloading '<a href="http://localhost/ServiceModelSamples/service" rel="nofollow">http://localhost/ServiceModelSamples/service</a>'.<br>
    The request failed with HTTP status 404: Not Found.</p>
  </blockquote>
  
  <p>here is my app.config</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
  &lt;configuration&gt;
  &lt;system.serviceModel&gt;
  &lt;services&gt;
    &lt;service behaviorConfiguration="CalculatorServiceBehavior" name="Microsoft.ServiceModel.Samples.CalculatorService"&gt;
      &lt;endpoint address="" binding="basicHttpBinding" contract="Microsoft.ServiceModel.Samples.ICalculator" /&gt;
      &lt;endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /&gt;        
      &lt;host&gt;
        &lt;baseAddresses&gt;
          &lt;add baseAddress="http://localhost:8000/ServiceModelSamples/service" /&gt;
        &lt;/baseAddresses&gt;
      &lt;/host&gt;
    &lt;/service&gt;
  &lt;/services&gt;
  &lt;bindings&gt;
  &lt;/bindings&gt;
  &lt;behaviors&gt;
    &lt;serviceBehaviors&gt;
      &lt;behavior name="CalculatorServiceBehavior"&gt;
        &lt;serviceMetadata httpGetEnabled="true" /&gt;
        &lt;serviceDebug includeExceptionDetailInFaults="false" /&gt;
      &lt;/behavior&gt;        
    &lt;/serviceBehaviors&gt;
  &lt;/behaviors&gt;
  &lt;/system.serviceModel&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>As you can see its a slight modification to the tutorial found on msdn for hosting a WCF service in a Windows Service.</p>
  
  <p>I have tried reaserching this but haven't found much or most of the issues seem related to IIS hosting.</p>
  
  <p>UPDATE</p>
  
  <p>After adding the port number as suggested by venerik, the error has now changed to the following.</p>
  
  <blockquote>
    <p>Error: Cannot obtain Metadata from <a href="http://localhost:8000/ServiceModelSamples/service" rel="nofollow">http://localhost:8000/ServiceModelSamples/service</a> If this is a Windows (R) Communication Foundation service to which you have access, please check that you have enabled metadata publishing at the specified address.  For help enabling metadata publishing, please refer to the MSDN documentation at <a href="http://go.microsoft.com/fwlink/?LinkId=65455.WS-Metadata" rel="nofollow">http://go.microsoft.com/fwlink/?LinkId=65455.WS-Metadata</a> Exchange Error    URI: <a href="http://localhost:8000/ServiceModelSamples/service" rel="nofollow">http://localhost:8000/ServiceModelSamples/service</a>    Metadata contains a reference that cannot be resolved: '<a href="http://localhost:8000/ServiceModelSamples/service" rel="nofollow">http://localhost:8000/ServiceModelSamples/service</a>'.    There was no endpoint listening at <a href="http://localhost:8000/ServiceModelSamples/service" rel="nofollow">http://localhost:8000/ServiceModelSamples/service</a> that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.    Unable to connect to the remote server    No connection could be made because the target machine actively refused it 127.0.0.1:8000HTTP GET Error    URI: <a href="http://localhost:8000/ServiceModelSamples/service" rel="nofollow">http://localhost:8000/ServiceModelSamples/service</a>    There was an error downloading '<a href="http://localhost:8000/ServiceModelSamples/service" rel="nofollow">http://localhost:8000/ServiceModelSamples/service</a>'.    Unable to connect to the remote server    No connection could be made because the target machine actively refused it 127.0.0.1:8000</p>
  </blockquote>