Reputation: 399
I've scrapped what I was working with and went to the simplest of code:
class Program
{
static void Main(string[] args)
{
var nancyHost = new Nancy.Hosting.Self.NancyHost(new Uri("http://localhost:8080"));
nancyHost.Start();
Console.ReadLine();
nancyHost.Stop();
}
}
public class MainModule : Nancy.NancyModule
{
public MainModule()
{
Get["/"] = x =>
{
return "Hello world!";
};
}
}
When I browse to
http://localhost:8080
I get:
Service Unavailable
HTTP Error 503. The service is unavailable.
I've tried several solutions. Including several variations on: Remote access to a Nancy Self Host
Any ideas?
Upvotes: 5
Views: 3254
Reputation: 155
I don't how much value this answer will have, but I did encounter this same 503 error when I started Nancy with this combination of settings:
_nancyHost = new NancyHost(new HostConfiguration {
RewriteLocalhost = false
},
new Uri(string.Format("http://localhost:{0}", port)));
The error was encountered when using a local browser accessing http://localhost:3684/ to Nancy running in a Windows Service as Local System
The prior revision with RewriteLocalHost
on default setting of true had been working. This was one of the things I was trying while attempting to diagnose my question here: How do I remotely access self-hosted Nancy service?
Upvotes: 0
Reputation: 9616
Make sure you are running Visual Studio as Administrator and that 8080
is not used by something else at the same time. Have a look at the self-hosting demo which sets up a couple of different URIs for a self-hosted application https://github.com/NancyFx/Nancy/blob/master/src/Nancy.Demo.Hosting.Self/Program.cs#L12
Upvotes: 5