Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I had to change my default apache port number 80 to 8123 (just random number)

I changed the following files ..

httpd.conf

Listen 8123
ServerName localhost:8123

httpd-vhosts.conf

NameVirtualHost *:8123
<VirtualHost *:8123>
  ServerName localhost
  DocumentRoot "C:/xampp/htdocs"
  DirectoryIndex index.php
</VirtualHost>

Windows Hosts file

127.0.0.1:8123     localhost
::1:8123           localhost

I am using Windows 7.

After making all these changes, I restarted apache but I am still unable to access http://localhost .... however http://localhost:8123 works fine ... can someone help me find what I am doing wrong here? thanks

share|improve this question
Adding a port number to an ip address in a hosts file does not makse sense. The hosts file is to create a relation between an ip address and one or more host names. The first entry in a hosts file has to be an ip address only! The follwing entries shall be host names. – alk Oct 31 '12 at 10:27
If you tell a server not to listen on port xyz, it doesn't listen on port xyz, that's it. – alk Oct 31 '12 at 10:29

closed as off topic by alk, Jon B, bensiu, LittleBobbyTables, skolima Oct 31 '12 at 12:52

Questions on Stack Overflow are expected to relate to programming or software development within the scope defined in the FAQ. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about closed questions here.

2 Answers

The only way to do this is to change back to 80, or to install a listener on port 80 (like a proxy) that redirects all your traffic to port 8123.

When you enter a server name without a port, port 80 is assumed by default. AFAIK, there is no way to change this behaviour without changing your browser's source code.

The hosts file does not support the kind of redirection you are trying to do. The rules simply fail.

Edit: ah, it might be possible to change the default port in some browsers. Here's an article in MozillaZine for Firefox.

share|improve this answer
thanks - I'll try changing browser default port – user1421214 Oct 31 '12 at 10:47

You can remove it with proxyPass and proxyPassReverse

<VirtualHost *>
    ServerName localhost
    ProxyPass / http://127.0.0.1:8123/ 
    ProxyPassReverse / http://127.0.0.1:8123/ 
</VirtualHost>
share|improve this answer
Hmm ... let me try that – user1421214 Oct 31 '12 at 10:17
See this answer at serverfault – J.A.I.L. Oct 31 '12 at 10:31
no luck :( ..... – user1421214 Oct 31 '12 at 10:51
Did you try with different IPs? – J.A.I.L. Oct 31 '12 at 10:53
diff? I tried first with 127.0.0.1 and then tried localhost – user1421214 Oct 31 '12 at 10:57
show 2 more comments

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