I installed easyPHP and opened a port on my firewall so that other people can access to my webserver. The default port is 8888. But I am wondering how do you choose a port number? Is it really ambiguous or there is a "prefered" range of port number?

  • 1
    Generally any port is fine. The reason why many apps use ports like 8888 or 8080 is those are non-admin level ports so many end users without admin rights can just start up a server. This works on pro web applications as well. But many times what happens with those applications a front-end web proxy connects 8080 or 8888 to port 80. Generally you should just use port 80 for ease of access. Anything else would require something like 123.456.789.0:8080 or example:8080. – Giacomo1968 Jul 24 '18 at 2:45
  • @JakeGould Thanks for your comment it really helped me.! – GeneCode Jul 24 '18 at 2:56
  • Possibly related question: stackoverflow.com/questions/10476987/… – glenneroo Jul 24 '18 at 18:48

A port number is a 16-bit unsigned integer, thus ranging from 0 to 65535 (although 0 cannot be used for TCP; it has a special meaning for UDP).

You can use pretty much any port number in the range, however there are some guiding rules:

  1. (On Unix based systems at least), only root can bind to ports below 1024.
  2. You ideally don't want a port typically associated with another common service as this can cause problems with some firewalls.
  3. Expanding on (2) above - On Linux systems at least, there is a file /etc/services which has a list of common services - you can use this for guidance.

The "ideal" port to run an HTTP service is port 80, and the ideal port for HTTPS is 443, because those ports are associated with their respective services. If this is not practical (and it often isn't - some routers are too stupid to handle a web interface and port forward externally on the same port), it's common to pick a "themed" port - port 8080 is pretty common, as is port 8000.

  • 1
    On modern Windows versions you have to have administrator privileges in order to bind to ports below 1024 as well. – enkryptor Jul 24 '18 at 9:54
  • @enkryptor: Which versions are those? Is this documented anywhere? – user1686 Jul 24 '18 at 13:25
  • @grawity I believe it's Windows 7 and later. You can also give a permission to a non-admin user for a specific url via netsh http add urlacl – enkryptor Jul 24 '18 at 13:31
  • @enkryptor I have nginx running on port 80, non-localhost ip, and I'm not admin in this system. – Braiam Jul 24 '18 at 13:52
  • @Braiam good for you – enkryptor Jul 24 '18 at 13:53

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.