Hi
I've been working on a joomla site on my local windoes vista computer using WAMPSERVER vrs2 and with apache.

Something went wrong with apache and windows warned me and turned it off. Since then I can't use http://localhost (or the shortcut on the wampserver menu 'localhost' to connect.

However I CAN connect using and this is the workaround I've been using for a week now. Anyone know how i can get my 'localhost' working back to normal?

Thanks for your time.

Dani AI

Generated

Good summary of the usual causes from and : a missing/altered hosts mapping, permission problems editing the hosts file, or Apache bound only to one address. A few additional, practical checks and fixes that address situations where typing a loopback IP (like 127.1.1.1) works but localhost does not.

Check what name resolution and listeners are doing:

  • See which address localhost resolves to with:

    ping localhost
    ping -4 localhost
    ping -6 localhost

    If localhost resolves to an IPv6 address (::1) while Apache is only listening on IPv4, that explains the behaviour. Confirm which process is using port 80:

    netstat -ano | findstr ":80"
    tasklist /fi "PID eq <pid-from-netstat>"

Look at logs and bindings:

  • Inspect Apache error/access logs and Windows Event Viewer for the time Apache stopped (mentioned by ). If Apache is bound to a single IP, change its Listen/VirtualHost settings to include IPv6 or all interfaces, or make localhost resolve to an IPv4 loopback as needed.

If the hosts file is read-only / access denied (as reported by ), the simplest safe approach is to open an editor elevated. If that is not possible, the ownership/permission commands below (run in an elevated prompt) restore edit ability:

attrib -r %windir%\System32\drivers\etc\hosts
takeown /f %windir%\System32\drivers\etc\hosts
icacls %windir%\System32\drivers\etc\hosts /grant "%USERNAME%":F

After editing, flush the resolver cache and restart services:

ipconfig /flushdns
(restart Apache/WampServer)

Extra notes: 127.1.1.1 works because the entire 127.0.0.0/8 block is loopback. Avoid duplicate host entries (per ), and revert overly-permissive file ACL changes when finished. Checking these items covers the common scenarios where 127.x.x.x connects but localhost does not.

Recommended Answers

All 6 Replies

Open Notepad/Wordpad and navigate to
<Your Windows Drive (C:/)>/windows/system32/drivers/etc/hosts
(You might need to change Text Document (*.txt) to all files to see it)
It should look something like this:

# Copyright (c) 1993-1999 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
#      102.54.94.97     rhino.acme.com          # source server
#       38.25.63.10     x.acme.com              # x client host

127.0.0.1       localhost

Add this line to the bottom of the file:

localhost
so your hosts should look like this:

# Copyright (c) 1993-1999 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
#      102.54.94.97     rhino.acme.com          # source server
#       38.25.63.10     x.acme.com              # x client host

127.0.0.1       localhost
127.1.1.1	localhost

Hope that helps,
Sam R

check you hosts file in notepad.

start - run
%windir%/system32/drivers/etc

If your in a work group then this file controls you manual dns mappings.

Your should have a default entry:

127.0.0.1 localhost

sorry shoud have refreshed the page !

Just a note I would not have two entries using the same host name.

sorry shoud have refreshed the page !

Just a note I would not have two entries using the same host name.

Yer soz, i wrote that during a Geography lesson and I wasn't thinking propperli :D

Thanks for that. By the time I had seen your reply I had already figured this out (actually remembered that there was a 'variable - name' pairing in hosts file. And yes localhost had somehow been removed. I replaced it and all is working fine. Thank you for your help.
Must check my profile though - don't remember getting any emails telling me a reply was made to this post - thanks again.

can't change hosts file, it said "read only" - "access denied"

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.