Celeb Glow
news | March 13, 2026

Can I use the same port on 127.0.0.1 and 192.168.x.x

I don't quite understand how localhost relates to the private IP assigned to each machine.

If I run a server on localhost:8080, can I run something else on 192.168.x.x:8080?

More specifically if I run a python waitress server on localhost:8080 and use NGINX to reverse proxy, can I have NGINX listen on port 8080?

2 Answers

If I run a server on localhost:8080, can I run something else on 192.168.x.x:8080?

Yes, there can be different listening sockets on the same port as long as they're bound to different local addresses (i.e. the sockets are tracked according to address:port combinations).

(But avoid mixing specific address:port listeners with the "any address" 0.0.0.0:port or [::]:port listener. Usually that's also allowed but has stricter requirements, e.g. I think Linux disallows this if the two programs have different UIDs.)

I don't quite understand how localhost relates to the private IP assigned to each machine.

It doesn't. The name "localhost" specifically resolves to the addresses 127.0.0.1 and [::1], nothing else. It never uses your actual LAN addresses.

localhost translates to 127.0.0.1, so localhost:8080 and 127.0.0.1:8080 are the same thing.

192.168.x.x is a different IP address, therefore the same port can be reused. You can run different servers on 127.0.0.1:8080 and on 192.168.0.1:8080, and if you have more IP addresses, you can even go on with e.g.: 192.168.0.2:8080 and 192.168.0.3:8080

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

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