Is there a way to serve a webpage from a locally running tcp server listening on a unix domain socket instead of localhost:<port>?

something like:


my only real motivation is to avoid port conflicts in the 2000-5000 range.


1 Answer 1



It is easy to serve it.


But harder to get the client to use it.

An alternative

However because you told me why you are doing it, I have another solution.

You want several web-servers to serve to only the local machine, but not have conflicts of port. It may also be nice if they all used the same port number.

Loopback addresses are That is 127.x.x.x not just

Therefore use a different IP address for each server. E.g., ...

  • cool, I can try the other loopback addresses. Could you add an example of using unix sockets as well? just curious how it would work. Mar 30, 2020 at 17:41
  • I don't know if the servers are programmed to do it. But you could listen on a high port, and use port forwarding. I just went for multiple loop-back addresses. Mar 30, 2020 at 19:49
  • yeah the multiple loop back addresses is cool. will prob use that. but I am really curious how it could be done with unix domain sockets, any idea how? Mar 30, 2020 at 22:47
  • 1
    I would look at netcat. It may be able to forward it. ssh can do it but there is overhead of encryption. Both would need the server to listen on a socket, and would just forward from another unix socket. I think I did it once. But could not convince the browser to use it. I would ask another question. But be clear about what you are not asking for, and link to this question. Mar 31, 2020 at 19:18
  • 1
    yeah but netcat would be listening on a port and then forwarding to the unix domain socket? ultimately I am trying to avoid listening on a port at all, so that defeats the purpose, but your original idea to use a different loopback address is good. Mar 31, 2020 at 19:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.