27

I'm building an ASP.NET website - it's a solution with a few projects, a data base and a web service. Everything worked fine, but last time I tried to run the project, I got the following error:

There was no endpoint listening at http://localhost:[number]/BooksWS.svc that could accept the
message. This is often caused by an incorrect address or SOAP action. See InnerException, 
if present, for more details.

The inner exception says:

Unable to connect to the remote server

This error sort of came out of the blue, so I'm not sure what additional information I should provide. Does anyone have any idea why this could happen?

I suppose even a general answer could help, the only info I found about this error in the web concerned WCF.

Cheshie
  • 2,777
  • 6
  • 32
  • 51
  • The remote service isn't up, or you're hitting the wrong port. – Lynn Crumbling Jun 26 '14 at 18:46
  • @LynnCrumbling, I also suspect something about the wrong port. Do you know how I could fix it? – Cheshie Jun 26 '14 at 18:47
  • 1
    From this message, you're hitting 5758. Did you pick that? Are you using Visual Studio's development server, and that was the random port? – Lynn Crumbling Jun 26 '14 at 18:49
  • Yup, I think it was a random port... and you're right, my project is trying to connect with a different port (no idea why). How do I change that, manually with the web.config page? Thanks so much! – Cheshie Jun 26 '14 at 18:53
  • 4
    A good thing is to: 1) run another instance of VisualStudio, (if you control the server-side of the application as well). 2) In that Visual Studio launch the server Application in debug mode (internal IIS (or whatever) server environment). 3) Make sure, it runs and that it runs, where you want it to (address, port). 4) Reconfigure your solution (in this case 'client' so that it tries to connect to the 'server-visual-studio'). 5) Run it, if it comunicates well, then the problem is in the networking/firewalls/permissions or service server just not started. And yes, MOSTLY it is in Web/App.config – jmodrak Jun 26 '14 at 18:53
  • thanks @jmodrak. Concerning 3, uh, I said that it _didn't_ run, and I suppose it's because it's looking for the wrong port. Throughout my whole solution it says that the port is 5758, but when I launch the project in a browser, it says that it's looking for a different port (one that I can't see mentioned in my project). I wonder - do I now have to change the 5758 that appear throughout the whole project? – Cheshie Jun 26 '14 at 19:01
  • 2
    @Cheshie You missed the point, What I am supposing is you to start the server on (example) localhost:5758 using VisualStudio, just to make sure, that the fault is not on the side of your application and neither on the communication side. If you do not control the server application, then you can mock it (or its behaviour), that is, run a small little service, that pretends to be the service, you want to call (it can be significantly smaller, just to find out and test). If you proceed well, call it, get response, then you know exactly, where the problem is not, which is also helpful, i guess. – jmodrak Jun 26 '14 at 19:05
  • I had the same issue, in my case it worked in Visual Studio locally, but not worked once I deployed to Cloud, I got the "no endpoint" issue. The problem is the service is available only with in the Company network not in Public network. So check the scope of that service. – Vijai Aug 07 '19 at 17:50

12 Answers12

20

go to webconfig page of your site, look for the tag endpoint, and check the port in the address attribute, maybe there was a change in the port number

dandush
  • 256
  • 2
  • 9
13

Another case I just had - when the request size is bigger than the request size set in IIS as a limit, then you can get that error too.

Check the IIS request limit and increase it if it's lower than you need. Here is how you can check and change the IIS request limit:

  1. Open the IIS
  2. Click your site and/or your mapped application
  3. Click on Feature view and click Request Filtering
  4. Click - Edit Feature Settings.

Edit Feature Settings

I just found also another thread in stack IIS 7.5 hosted WCF service throws EndpointNotFoundException with 404 only for large requests

Community
  • 1
  • 1
LyuboBG
  • 171
  • 1
  • 4
6

An another possible case is make sure that you have installed WCF Activation feature. Go to Server Manager > Features > Add Features

enter image description here

Milan Matějka
  • 2,654
  • 1
  • 21
  • 23
4

I had this problem when I was trying to call a WCF service hosted in a new server from a windows application from my local. I was getting same error message and at end had this "No connection could be made because the target machine actively refused it 127.0.0.1:8888". I donot know whether I am wrong or correct but I feel whenever the server was getting request from my windows application it is routing to something else. So I did some reading and added below in Web.config of service host project. After that everything worked like a magic.

<system.net>
    <defaultProxy enabled="false">
    </defaultProxy>
</system.net>
Ziggler
  • 3,361
  • 3
  • 43
  • 61
2

Short answer but did you have Skype open? This interferes specifically with ASP.NET by default (and localhosts in general) using port:80.

In Windows: Go to Tools -> Options -> Advanced -> Connection and uncheck the box "use port 80 and 443 as alternatives for incoming connections".

Danny Mahoney
  • 1,255
  • 2
  • 13
  • 24
2

Try this:

  • Delete the service instance.
  • Create a new instance of the service.

Sometimes the port is changed and generated error.

2

I tried a bunch of these ideas to get HTTPS working, but the key for me was adding the protocol mapping. Here's what my server config file looks like, this works for both HTTP and HTTPS client connections:

  <system.serviceModel>
    <protocolMapping>
      <add scheme="https" binding="wsHttpBinding" bindingConfiguration="TransportSecurityBinding" />
    </protocolMapping>
    <services>
      <service name="FeatureService" behaviorConfiguration="HttpsBehavior">
        <endpoint address="soap" binding="wsHttpBinding" contract="MyServices.IFeature" bindingConfiguration="TransportSecurityBinding" />
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="HttpsBehavior">
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
        <behavior name="">
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <bindings>
      <wsHttpBinding>
        <binding name="TransportSecurityBinding" maxReceivedMessageSize="2147483647">
          <security mode="Transport">
            <transport clientCredentialType="None" />
          </security>
        </binding>
      </wsHttpBinding>
    </bindings>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
mikegracer
  • 41
  • 6
1

If you are using custom binding, please make sure that you are putting the same name for both custom binding (Server and Client)in config files

<bindings>
<customBinding>
 <binding name="BufferedHttpServerNoAuth" closeTimeout="00:10:00" openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00">
          <gzipMessageEncoding innerMessageEncoding="textMessageEncoding" MaxArrayLength="10485760" MaxBytesPerRead="31457280" MaxStringContentLength="102400000" />
          <httpsTransport hostNameComparisonMode="StrongWildcard" manualAddressing="False" maxReceivedMessageSize="31457280" authenticationScheme="Anonymous" bypassProxyOnLocal="True" realm="" useDefaultWebProxy="False" />
</binding>
</customBinding>
</bindings>

the binding name "BufferedHttpServerNoAuth" should be same in both.

Hope this would help someone

dush88c
  • 1,918
  • 1
  • 27
  • 34
1

This is ancient history but I just ran into this issue and the fix for me was recycling the application pool of the website in IIS. Easy fix, for once.

Doug F
  • 894
  • 2
  • 13
  • 18
1

I changed my website and app bindings to a new port and it worked for me. This error might occur because the port the website uses is not available. Hence sometimes the problem is solved by simply restarting the machine

-Edit-

Alternative (and easier) solution:reference

  1. Get PID of process which is using the port CMD command- netstat -aon | findstr 0.0:80

Command 1

  1. Use the PID to get process name -

tasklist /FI "PID eq "

Command2

  1. Open task manager, find this process and stop it.

(Note- Make sure you do not stop Net.tcp services)

Loony_D
  • 31
  • 5
  • You could also stop the process by running "taskkill /F /IM OneApp.IGCC.WinService.exe" or "taskkill /F /PID 4188" – nardnob Dec 16 '20 at 14:53
0

I solved it by passing the binding with endpoint.
"http://abcd.net/SampleFileService.svc/basicHttpWSSecurity"

Raj Chaurasia
  • 1,976
  • 1
  • 11
  • 10
0

Click on Service which you have created right click on it then select update references after this rebuild the application it will work