3

I'm working on an app that uses HttpListener() extensively. So far I've been doing all my testing on an actual network, but I'm pretty sick of this now.

I've tried the usual suspects (localhost, 127.0.0.1) with the correct port, but nothing happens.

Is there a setting in Windows somewhere? (Is it obvious I'm a *nix boy normally?)

Tom Wright
  • 11,278
  • 15
  • 74
  • 148

2 Answers2

5

Both localhost and 127.0.0.1 should work fine.

I suspect you have a firewall (such as Windows Firewall) that's preventing connections on your local box. Disable it while you're doing your testing.

Reed Copsey
  • 554,122
  • 78
  • 1,158
  • 1,373
  • Damn. Was dreading this response - the firewalls on our machines can't be touched by mortals. (My place of work fails the Joel test. Hard.) – Tom Wright Feb 03 '11 at 18:46
  • Or you are kicking off your listener using Visual Studio and it is using a specific port so check that as well. – phillip Feb 03 '11 at 18:47
  • @Tom: Yeah - if you have a local firewall, it's probably blocking the ports... I'd check this first, but that's most likely the problem – Reed Copsey Feb 03 '11 at 18:47
  • @phillip: I specify a port normally, and have no problem accessing it when it's located on other machines. I'm not sure I fully grasp what you're saying..? – Tom Wright Feb 03 '11 at 18:48
  • Yeah... I just wanted to make sure you understood that VS can set your ports for you automatically. Sometimes that can be confuse people. – phillip Feb 03 '11 at 20:12
0

Http.sys (which underpins HttpListener) dies not allow access by default unless you are running as an admin. You can enable this using httpcfg (xp) or netsh (vista, win7 etc).

See also this question

This is separate to the firewall; for external connections you will also need to open a small hole in the firewall.

Community
  • 1
  • 1
Marc Gravell
  • 1,026,079
  • 266
  • 2,566
  • 2,900