Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Changing the default http port to another one.

  1. May 28, 2006 #1
    I set up a server a while ago (I'm not very experienced in that kind of stuff). I have a router, and I forwarded ssh, smtp, and pop connections to the server, however my router provides an access to the settings through http, ( and I'd like to change default http port (80) to 9999 or any others except for 80 so that the http is forwarded to my server. Right now, whenever I try to access my server, by domain, I get to the router which I don't want to be there. Any ideas how I can do that?

    Last edited by a moderator: Apr 22, 2017
  2. jcsd
  3. May 28, 2006 #2


    User Avatar
    Science Advisor
    Homework Helper
    Gold Member

    Some routers (e.g. Netgear) allow you to change the port number for remote management, as well as restrict access to a certain set of IP addresses.

    You could also do this...
    turn off remote management. Then use (say) vnc or remote desktop (possibly via ssh) to access your computer and do the management locally. However, this may not work as well since your connection may drop if you need to reboot the router.
  4. May 29, 2006 #3


    User Avatar
    Science Advisor

    There's a couple of things to keep in mind. I'm assuming you have a configuration similar to the following:
    . WAN IP (given by yur ISP)
    . LAN IP

    . LAN IP

    Most routers have HTTP based administration on port 80, as you mentioned, but usually only from the LAN side (WAN side administration has to be specificaly enabled, and it is usually over a custom port, like 8080). If you set your router to forward port 80 to your server then:
    . should take you to your server
    . should take you to the router's HTTP based administration
    (Notice that port forwarding forwards requests on the specified ports from the WAN side only)
    It's OK to have the router's HTTP based administration on port 80 from the LAN side, this should not cause any problems with your website. Also, forwarding port 80 won't make the router's HTTP based administration unavailable. So forward port 80 to your server, once you have that, then:
    . will take you to your website
    . will take you to your website
    . http://localhost will take you to your website
    . will take you to your router's HTTP based administration
    . will take you to your router's HTTP based administration (if you enable remote administration through port 8080).

    You can also easily have your web server listening on some port other than 80, like 6969 and have your router forward WAN requests on port 80 to your server on port 6969.
    Last edited by a moderator: Apr 22, 2017
  5. Jun 4, 2006 #4
    I tried this method above, but it ain't working. Although my router is set up not to allow remote administration, I still can access to it through my domain, from far, far away. Maybe the best thing would be to make apache listen onto another port, since my website is just for me and practice, and leave router at 80. It'd rather be more convenient for me to make my server listening to for example 666. But then again, how can I make apache listen to another port?
    Thanks Job
  6. Jun 4, 2006 #5


    User Avatar
    Science Advisor

    To configure Apache to listen on a given port you have to edit the configuration file, i think it's httpd.config. You need to use the appropriate directive, here's some help:

    What kind of router do you have? Sounds like a strange router.
  7. Jun 4, 2006 #6
    hmm it's quite weird. I wrote into httpd.conf Listen 668, but when I try to restart apache, I get:
    (98)Address already in use: make_sock: could not bind to address
    no listening sockets available, shutting down

    any ideas Job?

    Thanks again,
  8. Jun 8, 2006 #7


    User Avatar
    Science Advisor

    Sounds like something else is using the port, or you didn't specify a valid interface address. I'm actually more of an IIS kind of guy. :smile:
  9. Jun 8, 2006 #8


    User Avatar

    Staff: Mentor

    No, what you want is the "Port" directive. (Gee, what an obscure name! :eek: ) Your httpd.conf almost certainly contains "Port 80" already. Just change the 80 to whatever new port you want and restart the server. Don't forget to tack the port number onto the host name or IP in the URL.

    According to the Apache docs, you use the "Listen" directive when you want the server to listen to more than one port simultaneously, for example when you're running different virtual hosts on different ports.

    Also, it's not a good idea to use a port below 1024, because those are often reserved by the operating system for other uses. Try something like 8080 or 8100 or 8000.
    Last edited: Jun 8, 2006
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook