24

I have a big problem opening http://localhost/ on Windows 7 (beta). I installed this os and everything went great; when I installed Wamp I saw that localhost is not working at all. I just see this error:

Failed to Connect

Firefox can't establish a connection to the server at localhost.

in Mozilla and Explorer.

I removed Wamp and after some weeks (that means two weeks from today) I installed NetBeans on Windows 7. I created a test PHP script and when I debug it, I get the same error again. I tried to access it with ip 127.... but still the same. What is the problem?
When i installed NetBeans I installed it in port 8080.

Mukesh Chapagain
  • 25,063
  • 15
  • 119
  • 120
AXheladini
  • 1,776
  • 6
  • 21
  • 42

22 Answers22

22

If you installed it on port 8080, you need to access it on port 8080:

http://localhost:8080 or http://127.0.0.1:8080

FlySwat
  • 172,459
  • 74
  • 246
  • 311
21

To fix the port 80 problem do:

From cmd as administrator:

  1. sc config http start= demand (you need a space after the equal sign and not before)
  2. Reboot
  3. Run the command (netsh http show servicestate) as administrator to check that the port 80 is in use

After you have run this command, you can disable http.sys as follows:

  1. net stop http (stop the process)
  2. Sc config http start= disabled (if you want to disable the service forever)

it works for me.

Nick Garvey
  • 2,980
  • 24
  • 31
fabio
  • 226
  • 2
  • 2
  • 1
    In my case MS Deploy was using port 80. I am able to find that using netsh http show servicestate command you mentioned.. And then I also disabled other services as you mentioned. And its started working. Thanks for sharing. – Krunal Feb 04 '14 at 04:56
  • Fabio and Nick you are the saver of the BACON! Thanks guys. – gadildafissh Mar 25 '14 at 07:17
  • When i run sc config http start= demand it says access denied ? – ii iml0sto1 Oct 22 '18 at 13:37
12

Edit your C:\Windows\System32\drivers\etc\hosts file

Make sure there is an entry that looks like this:

127.0.0.1   localhost

If there is an entry like

::  localhost

Comment it out to look like this

\#:: localhost

This should fix your problem, I've had this problem in the past.

samayo
  • 16,163
  • 12
  • 91
  • 106
  • This is how that part of file looks file looks: # localhost name resolution is handle within DNS itself. # 127.0.0.1 localhost # ::1 localhost i try to change them but when i save them i dont know with what extension to save that file ? – AXheladini May 01 '09 at 21:52
  • 1
    For my installation, 127.0.0.1 localhost was commented out by default. just make it active. Note: you need to have admin privileges on Win 7 to save and if you navigate by explorer you won't even see the etc folder unless you have admin privileges turn on. – James John McGuire 'Jahmic' Jan 24 '12 at 05:52
  • +1, this fixed it for me as well. Can't believe Windows 7 would comment this out by default.... For those having problems editing or saving the file, you may need to right-click on your text editor icon/executable and "Run as Administrator" in order to be able to modify system files. – Amos M. Carpenter Aug 01 '12 at 00:18
6

It sounds like you have no web server running at all anywhere.

Have you tried enabling IIS and using it to display a basic html file first?

Programs & Features -> Turn Windows Features On/Off -> Internet Information Servcies

Then, place your html file in C:\inetpub\wwwroot\index.html and browse to http://localhost.

Once this works, try to get WAMP/php working. Be careful of port conflicts.

BenB
  • 10,300
  • 7
  • 32
  • 30
6

For me, it was skype causing the problem. Once I stopped skype, everything worked. I have 1.7.1 xampp (mysql and apache) running on Windows 7 x64.

3

My initial thought is that you are missing an entry in the hosts file. Something like "127.0.0.1 localhost", however, you mention that you are getting a 404 error. That means that the webserver is connecting to your client/browser and responding to the request for a particular webpage.

I'm not familiar enough with Windows 7, however, I'm pretty sure that it does not include a webserver by default. Also, unless you actually code, build and run a webserver application using netbeans you're not going to get the desired response.

When it comes down to it.... your issue is going to be one of the following:

1) you're serving static documents and the webserver is not configured to serve the files from whatever the proper DOCROOT should be. This includes PUBLIC folders in the user's directories. (the basic apache install include a basic homepage)

2) you have a dynamic webserver application where the controller is looking at the application path in order to decide what page to display or what function to execute. (see MVC - Controller). Basically incomplete implementation.

3) yet another configuration error: your website might actually define a virtual domain. (something other than localhost) so when you look for localhost in the URL the server might not be configured to provide a default page.

Richard
  • 10,122
  • 10
  • 42
  • 61
  • No i saw now that the error is this: Failed to Connect Firefox can't establish a connection to the server at localhost. – AXheladini May 01 '09 at 21:42
  • Well, if it failed to establish the connection then the issue is that the webserver is either not running, running on a different port (see other comments), or the firewall is blocking access. – Richard May 01 '09 at 21:51
  • What kind of webserver is installed with NetBeans ? – AXheladini May 01 '09 at 22:02
  • current netbeans supports Glassfish application server and tomcat servlet container. – Richard May 01 '09 at 22:40
2

Uncommenting the following line in host file worked for me,

#127.0.0.1 localhost
Shawn Chin
  • 84,080
  • 19
  • 162
  • 191
Abid
  • 21
  • 1
1

Yea, this was a pain for me as well.

So what i did was find the "Start Wampserver", just hit the start button and type it in.

Then right click on it , select properties. I set it to run in XP servive pack 3 on the capatability tab. I also checked the box "Run this program as an administrator".

Then I right clicked the WAMPSERVER on the System Tray, and re-started all services. This worked perfect for me, hope this will help you as well.

Rob

1

Got any other Programs running ? msn ect... ? some bind to port 8080 then your webserver wouldnt start and would cause a 404 , try binding it to a different port 80 which its default should be

1

I got a 404 could not connect error then I set wampmanager.exe to run as Xp Sp3 and it seems to be working fine this can be done by


  1. Right Clicking on it
  2. Properties
  3. click tab labled "Compatibility"
  4. Tick Box just undeder "Compatibility mode"
  5. Select Windows XP (Service Pack 3)
  6. Click Apply then OK

1

It was Skype interfering for me too. I changed the Skype settings (in Skype go to Tools > options > advanced > Connection and UNCHECK "use port 80 and 443 as alternatives for incoming connections") save then close Skype. I have Win 7 HomePremium 64 bit, had installed Xampp fine with MySQL running fine, but no matter how many times I started Apache (and console showed "Apache started") I still got the "firefox can't establish a connection" error in the browser. After Skype changes were saved, Apache showed the green "Running" and all working now thanks

TechHater
  • 11
  • 1
1

For me this did the trick at port 80 in the end:

  • You have to disable the http.sys service manually via the registry:

    1. Launch RegEdit:
    2. Go to: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\HTTP
    3. Add a new DWORD (32-bit) value
    4. Name it ‘NoRun’ not including the quotes
    5. Double click the new property
    6. In the Value data field type ’1' not including quotes and click OK
    7. Re-boot your computer

You should now find that Apache will start on port 80!

Cosmin
  • 21,216
  • 5
  • 45
  • 60
Rob
  • 11
  • 1
1

Well you are getting a 404, so the web server is running, it just can't find the file.

Check the http.conf file. If it pointing to the right root directory?

If you are using different ports, then check http.conf to see if Apache is listening on the right port, or if apache is redirecting traffic on the port to anther root directory.

Maybe posting your http.conf file might help?

Matt
  • 7,022
  • 16
  • 53
  • 66
  • I am installing NetBeans for first time and i dont know where to find http.conf file, any idea where can it be ? – AXheladini May 01 '09 at 21:38
  • this is this is the error i get from firefox Failed to Connect Firefox can't establish a connection to the server at localhost. – AXheladini May 01 '09 at 21:42
  • Oops. I thought he said something about a 404. Checking the http.conf file is probably still a good idea though? – Matt May 04 '09 at 16:14
1

If you're still having this problem, try this:

  1. Edit your hosts file (with elevated privileges)
  2. Uncomment the line "#127.0.0.1 localhost" (ie- remove the #)
  3. Save the file as is. hosts with no extension

In Win7 MS has decided to comment the localhost line with that msg that says it's handled in dns. I'm still not exactly clear what they're getting at, except maybe that they're telling folks to use dns for localhost resolution instead of the hosts file. Probably safer that way, anyway.

squillman
  • 13,363
  • 3
  • 41
  • 60
0

Assuming there is no problem doing a lookup on localhost (to 127.0.0.1), you need to make sure your server is listening to 127.0.0.1.

netstat works in both windows an UNIX. You probably need "netstat -a" to display listeners.

samayo
  • 16,163
  • 12
  • 91
  • 106
benc
  • 1,381
  • 5
  • 31
  • 39
0

Maybe Skype or other Application is using port 80. This you can check in

Tools->Settings->Advanced->Connection

NormundsP
  • 445
  • 2
  • 7
  • 16
Prince
  • 1,280
  • 3
  • 25
  • 52
0

you have to install the service, go to wamp->Apache->Service->Install service, then a command prompt window will pop up, then press enter, and after a few seconds go to the same route Services-> and click Start/Resume service, and you ready

anteg
  • 1
0

Try adding the following tags in the wwwroot folder web.config file. These tags should be added as a child of the configuration tags as below.

-configuration-
--system.webServer--
---validation validateIntegratedModeConfiguration="false" ---
--/system.webServer--
-/configuration-
Ed Heal
  • 59,252
  • 17
  • 87
  • 127
0

I had the exact same issue, and the solution is what someone has already said:

In the taskbar, click on the WAMP icon.

Go to Apache-->Service-->Install Service

Then go back by clicking and selecting Apache-->Service-->Start/Resume Service

This will allow the localhost function to work (keep in mind I had already changed the host file located under c:\windows\system32\drivers\etc to remove the # from the 127.0.0.1 line)

If you need to edit that file still, you need to right click on it and select Properties. Then go to the Security tab, and click the Advanced button. You then need to select the Users, click Edit and select "Full Control". This will enable you to edit it.

That being said, you need to ALSO install the MySQL service following the same procedure.

MySQL-->Service-->Install Service

Then go back by right clicking yet again and selecting MySQL-->Service-->Start/Resume Service.

And that should fix it all up in Windows 7!

Rob
  • 153
  • 1
  • 2
  • 11
0

Before installing Wamp, go to controlpanel=> Adminstrative tools => IIS Manager and turn off the IIS server. Install wamp and everything works fine. When IIS is on it also uses port 80. You can go through a lot of changing the ports and permissions for wamp but I have found this the quickest and easiest method of getting wamp to run successfully.

Ddywalgi
  • 45
  • 4
  • 10
0

See the above solutions are very good.But whenever you get this 404 eroor,first see this.I am sure the problem will be solved...

Just go to httpd.conf file by clicking wamp server symbol in bottom right taskbar-Apache->httpd.conf... or c:\\wampt\\bin\\apache\\apache2.2.1\\conf\\httpd.conf and approximate on line no 46 you will find "Listen 80"...just make sure it is written "80" after Listen...if it not then change it to 80...And your problem will be solved...

samayo
  • 16,163
  • 12
  • 91
  • 106
abdul
  • 21
  • 6
0

Have you try the iis? Go to Control Panel->Programs and Features->Turn Windows features on or off (side bar). Try installing or reinstalling the Internet Information Service. I've a windows 7 with iis, with .net and php, and it works great...

Lucas
  • 339
  • 1
  • 4
  • i dont want to use iis since i want to try NetBeans. Do you think if i turn of IIS the problem can be solved ? – AXheladini May 01 '09 at 22:56