Reputation: 546
I have a self hosted Nancy application running on a Raspberry Pi and I can't get it to bind to port 80!
It works on port 81, 8090 and I even tried other "reserved" ports such as 443. They all work except 80.
I'm starting the app with sudo so it shouldn't be permissions and 81 works too.
sudo mono Lambda.Console.exe
The obvious culprit for this is that something else is using port 80 but I can't find out what it is. I have tried the usual;
netstat -ln - nothing is listening on port 80
telnet port 80 - connection is refused, suggesting nothing is listening
Does anyone have other suggestions? Can a process still be using the port? I'm stuck at this point.
Cheers
Dave
Upvotes: 4
Views: 977
Reputation: 546
I also found a work around for the issue that involves mapping port 80 to the port your Nacy app has actually bound too.
sudo /sbin/iptables -t nat -A PREROUTING -i eth+ -p tcp --dport 80 -j REDIRECT --to-port 8080
You can undo this using the same command but using -D instead of -A and if you want to check it exists then use -C
Ideally it would be best to use the Nancy patch from @david-karlas or if it comes along a mono fix but if you have to use an old mono version with old Nancy version then this works too.
Upvotes: 1
Reputation: 940
This is bug in Mono HttpListener I created pull request here: https://github.com/mono/mono/pull/891 Unfortunately I did not find workaround I will try to find robust workaround in Nancy since versions releases are more frequent.
Upvotes: 2