5

If I request http://localhost do browsers try a specific port?

Perhaps people set the default port server side? Or must ports be specified (eg. http://localhost:1234)?

I'm trying to make it as simple as I can for a client to connect to a locally hosted "remote controller" website.

4
  • 2
    http by default is port 80 while https defaults to 443. If you are hosting on a different port the client must specify which port.
    – Zina
    Commented Jul 31, 2017 at 21:27
  • strange. I though port numbers were 4 digits long. If setting up a port, would it be 0080. My current program crashes if given a less than four digit number... but perhaps that's an issue elsewhere.
    – Seph Reed
    Commented Jul 31, 2017 at 21:32
  • got it, sudo is required for ports < 1024
    – Seph Reed
    Commented Jul 31, 2017 at 21:35
  • 1
    setting up the port where? and BTW the port numbers are from 0 to 65535 see here for list of common port usage
    – Zina
    Commented Jul 31, 2017 at 21:36

2 Answers 2

10

If I request http://localhost do browsers try a specific port?

There are three well known ports commonly used by web servers:

You can, of course configure your local web server to use whatever ports you like.


Further Reading

4
  • 1
    Thank you. I've also just found that certain permissions (sudo) are required for ports < 1024.
    – Seph Reed
    Commented Jul 31, 2017 at 21:36
  • 1
    @SephReed On Unix systems, yes.
    – DavidPostill
    Commented Jul 31, 2017 at 21:37
  • I wasn't until I tried port 80 as per directed by this answer. It's not really in total relation to this question, but it still seems useful enough to share.
    – Seph Reed
    Commented Jul 31, 2017 at 21:39
  • This link, posted above, might be a nice thing to add to the answer, just to wrap everything up: iana.org/assignments/service-names-port-numbers/…
    – Seph Reed
    Commented Jul 31, 2017 at 21:39
5
  • Default HTTP Port: 80
  • Default HTTPS Port: 443

Following is some of the recommended localhost ports for local developments.

  • Recommended Express.js(or LoopBack ) Dev Port: 3000, 8000, 8080 (by npm start)
  • Default Angular Webpack Dev Port: 4200 (by ng serve)
  • Default Ionic Webpack Dev Port: 8100, 8200 (by ionic serve or ionic lab)

...

List of Well-Known Ports Port numbers range from 0 to 65535, but only port numbers 0 to 1023 are reserved for privileged services and designated as well-known ports. The following list of well-known port numbers specifies the port used by the server process as its contact port.

Well-known ports range from 0 through 1023. Registered ports are 1024 to 49151. Dynamic ports (also called private ports) are 49152 to 65535.

https://www.webopedia.com/quick_ref/portnumbers.asp

1
  • The default port in Laravel is also 80. (with php artisan serve) Commented Mar 28, 2019 at 10:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .