implement a 80 http port listener


I want to implement functionality similar to Fiddler.

I have tried 2 solutions:


HttpListener listener = new HttpListener();

When Start() is executed I get the error:

System.Net.HttpListenerException "The process cannot access the file because it is being used by another process"

which means that there is some other application listening on port 80 maybe IIS or whatever.


IPHostEntry ipHostInfo = Dns.Resolve(Dns.GetHostName());
IPAddress ipAddress = ipHostInfo.AddressList[0];
IPEndPoint localEndPoint = new IPEndPoint(ipAddress, 80);

// Create a TCP/IP socket.
Socket listener = new Socket(AddressFamily.InterNetwork,
    SocketType.Stream, ProtocolType.Tcp);

 // Bind the socket to the local endpoint and listen for incoming connections.
// .....

When listener.Bind() is executed I get:

System.Net.Sockets.SocketException (0x80004005): Only one usage of each socket address (protocol/network address/port) is normally permitted

which means the same thing, there is already another application listening on port 80.

So how does Fiddler listen to port 80 without these problems? I would prefer to use a class like HttpListener because it's higher level instead of a lower level class like socket where I have to implement the HTTP Protocol.

asked on Stack Overflow May 16, 2012 by Paul Rusu • edited Apr 26, 2021 by Jason Aller

2 Answers


That means something else is listening on port 80. You'll have to exit that application before yours will work.

answered on Stack Overflow May 16, 2012 by Peter Ritchie

So how does Fiddler listen to port 80 without these problems?

Fiddler is not accepting incoming connections on port 80 - it is acting as a proxy for outgoing HTTP connections. Some other application is using port 80 on your machine, so it is blocked for usage since there can only be one listener on a given port (in this case IIS as you mention in the comments).

answered on Stack Overflow May 16, 2012 by BrokenGlass

User contributions licensed under CC BY-SA 3.0