localhost problem on windows 7 - asp.net

I'm using Windows 7 Pro and want to run my web project locally, but the url www.localhost.com does not work.
If use http://127.0.0.1:2710/default.aspx it works. I checked host file which in the C:\Windows\System32\Drivers\Etc\hosts folder. If I delete the rows:
# 127.0.0.1 localhost
# ::1 localhost
Nothing changes. How can I make www.localhost.com work on my machine?

Hope I understand your question correct. You want to acces your local site using www.localhost.com
Just edit the hosts file and add the following lines
127.0.0.1 www.localhost.com
I checked my Windows 7 hosts file and it has the following lines
# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
# ::1 localhost
Above lines are comments and deleting those lines does not do anything.
Note: If you get "Access denied" when you save the hosts file then open notepad as Administrator and then edit hosts file and save it. It should work

EDIT: The rows you deleted were just comments, so that doesn't matter.
Were you trying to enter your url just as localhost
or as http://localhost:2710/default.aspx?
The latter is probably necessary, as the 2710 is the port number, and without it will default to port 80, which probably doesn't have anything listening on it.
UPDATE: It might actually be an IPv6 thing, so try it with just this line in your hosts file:
127.0.0.1 localhost
You should not have a # at the beginning of the line, that will disable that line.
(You might need to reboot too).
You could also try pinging localhost (just type ping localhost in a command prompt window) and check that you get a reply from 127.0.0.1

Did you try:
http://localhost:2710/default.aspx ?

Okay, simply put, your web project will run on http://localhost:2710/default.aspx, once you put those lines you removed back into the hosts file (More on it here). To get to remove the port number, you need to reconfigure your web server.
Now, if you want to get a domain, that's a different thing altogether... then, you need to get a registrar and use DNS to get it to map to you. You would do this if you wanted other people to be able to use something like www.site.com to get to your site.

Related

MAMP could not lookup up localhost. Website unavailable

A weird error appeared that all of a sudden http://localhost:8888/... is not available. A day ago it worked perfectly fine and now I get this error although I have not installed any software, nor updated MAMP nor updated my Operating System. I have been researching all day of what could be the problem and found several answers which solved other people's problem but sadly not mine. The question is: How can I get my localhost working again?
Once I enter the IP (http://127.0.0.1:8888) the website loads, however, all my links use http://localhost:8888, which means I would have to change all the links to use the IP. There are scripts that do so, but I really want to understand the background and find the root of this problem. I have tried several things:
Changing the Apache ports to another number which can be done under MAMP Preferences. I get the same error no matter which port I change it to.
Editing my etc/hosts file in order to link 127.0.0.1 to localhost, which I really did not have to do since the code was already there. After I have done this, I opened my terminal and entered sudo killall -HUP mDNSResponder in order to flush the DNS Cache. Afterwards, I restarted my computer and annoyingly the error keeps appearing. Somehow, localhost is not linked to 127.0.0.1, which I think is comparable to when the domain name of a website is not connected to the server IP which can be configured with the Nameservers. This brings me to my third point and last point.
I looked deeper into the location and opened the "httpd.conf" file found under the path "etc/apache2/httpd.conf" where I can configure the Apache HTTP Server. I searched for any ServerName and the only code that appears is some comments describing it. This includes #ServerName www.example.com:80 and a short description before. I've tried adding a new ServerName as ServerName localhost:8888 and even simply ServerName localhost, still nothing happens.
I've tried other obvious things which are not worthy mentioning for. This seems to me either something really complex to which my knowledge does not reach or something very silly I missed out.
For the record, the etc/hosts file contains some weird addresses:
##\n# Host Database\n#\n# localhost is used to configure the loopback interface\n# when the system is booting. Do not change this entry.\n##\n127.0.0.1 localhost\n255.255.255.255 broadcasthost\n::1 localhost \nfe80::1%lo0 localhost\n\n##SYS##\n127.0.0.1 inst.shoppingate.info\n127.0.0.1 service.shoppingate.info\n127.0.0.1 indexx.org\n127.0.0.1 f.flshbsjs.info\n127.0.0.1 gsy.testersgroupfun.com\n127.0.0.1 sendmessagebox.com\n127.0.0.1 t1.inskinad.com\n127.0.0.1 q.crbfmcjs.info\n127.0.0.1 static.donation-tools.org\n127.0.0.1 istatic.datafastguru.info\n127.0.0.1 static.boostsaves.com\n127.0.0.1 www.best-deals-products.com\n127.0.0.1 fge.solartrendinc.com\n127.0.0.1 nps.pastaleads.com\n127.0.0.1 digitaloptout.com\n127.0.0.1 cdncache-a.akamaihd.net\n127.0.0.1 cdncache1-a.akamaihd.net\n127.0.0.1 rvzr-a.akamaihd.net\n127.0.0.1 rvzr2-a.akamaihd.net\n127.0.0.1 asrv-a.akamaihd.net\n127.0.0.1 cdn.visadd.com\n127.0.0.1 a.visadd.com\n127.0.0.1 ydt.winsurfingclub.com\n127.0.0.1 client.foxydeal.com\n127.0.0.1 s.hklmm.com\n127.0.0.1 i.crbsjs.info\n127.0.0.1 wwm.determineyourroad.com\n127.0.0.1 ext1.engageya.com\n127.0.0.1 ext2.engageya.com\n127.0.0.1 a.tfxiq.com\n127.0.0.1 cdn.staticwebdom.com\n127.0.0.1 api.jollywallet.com\n127.0.0.1 i_crbsjs_info.tlscdn.com\n127.0.0.1 i_flshbsjs_info.tlscdn.com\n127.0.0.1 ppj.qwikbookprint.com\n127.0.0.1 homedesigntreasure.com\n127.0.0.1 www.superfish.com\n127.0.0.1 istatic.eshopcomp.com\n64.251.22.253 shmactustus.com\n64.251.22.253 www.google-analytics.com\n##SYS##
I also tried deleting all the remaining addresses leaving only:
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
fe80::1%lo0 localhost
But, after I restart my computer, all the old addresses I previously deleted appear again and the error is still the same. The thing is, this happened all of a sudden overnight and I did not expect this to occur. Does anybody know what is going on? I am open to any suggestions and appreciate your help. Best Regards!!

Localhost not found (404) iis

I am having several issues with the DNS localhost on my computer.
Some instruction is redirecting all my explorers, including visual studio somewhere else than 127.0.0.1 when I visual studio or any browser looks for localhost.
Where can such thing be happening? I recently changed my hosts file to point localhost somewhere else, but then it did not work so I switched it back, so that cant be the problem.
# Copyright (c) 1993-2009 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
# localhost name resolution is handled within DNS itself.
127.0.0.1 localhost
::1 localhost
I have also unistalled and installed IIS, so is not a problem of iis not redirecting properly..
I am not being able to run Visual Studio solutions because of this problem.
I have tried pining 127.0.0.1 and it responds, I have also tried localhost and it also works, but when I type localhost on a browser it redirects to a "404" page.
Make sure that IIS is actually configured to listen on 127.0.0.1 (perhaps you removed the binding previously?)
netsh http show iplisten
IP addresses present in the IP listen list:
127.0.0.1
You can add additional IPs like so:
netsh http add iplisten ipaddress=10.0.0.10
I just had this problem too and it turned out to be an issue with Default Web Site's bindings in IIS. I had specified the "Host Name" to be the server's domain name, meaning external access worked fine but trying to access any IIS page through localhost returned a browser 404 error.
Simply clearing that "Host Name" field and leaving it blank fixed the problem for me.
I added a binding to the site that accepted IP address 127.0.0.1 over port 80 and was able to connect.

Add subdomain to localhost URL

I am writing an web application that behaves differently depending on a url prefix. The format is something like:
https://myprefix.mycompany.com
The web app behaves differently based on myprefix. My web app extract that part from the URL and act on that.
However, when I test on my local, I use an localhost address:
https://localhost:1234
I counldn't do something like:
https://myprefix.localhost:1234
What is the best way for me to test this scenario?
Many thanks
Unfortunately, because localhost is not a proper domain, you can't add a subdomain to it like that. You can, however, trick your computer into thinking it owns a specific domain and test things that way. For instance, if you have a UNIX-based operating system, open (as root) the file /etc/hosts and add a line (or lines) like this:
127.0.0.1 example.com
127.0.0.1 subdomain.example.com
Your computer will now treat both example.com and subdomain.example.com as belonging to itself. If you visit either in your web browser, they will work the same, in principle, as localhost, but your web server will see the correct domain in its Host header.
I'm not sure about same behaviour on windows. I'm working on linux mint.
You can use lvh.me:port as a local domain. You can imagine that your project is deployed on localhost:port on this domain.
Instead of sub.localhost:port you've to use sub.lvh.me:port
UPDATE
sub.localhost:port works on Chrome.
Note: Firefox automatically adds www. at the beginning of entered domain that can cause problems with subdomains testing
For Windows users, based on this answer and per this comment, you can achieve this by adding ports to localhost via the hosts file that resides at this path:
C:\Windows\System32\drivers\etc\hosts
And append lines like the following to it:
127.0.0.1 example.com
127.0.0.1 subdomain.example.com
One-Line Solution for Windows
Open PowerShell as Administrator and run the following command, replacing sub.mydomain.com with whatever you want.
"`n127.0.0.1 sub.mydomain.com" | Out-File C:\Windows\System32\drivers\etc\hosts -encoding ASCII -append
Breakdown:
`n - newline
127.0.0.1 - loopback address
sub.mydomain.com - domain name
| Out-File C:\Windows\System32\drivers\etc\hosts - pipe the string to the hosts
-encoding ASCII - correct encoding
-append - append to end of file (important!)
You should be using the .test domain for things like that. That is what .test is for. localhost is not supposed to have any subdomains.
To do so violates the approved RFC standards. localhost has an A record and in IPv6 environments, an AAAA record. All other DNS record types, including SOA are forbidden.
Without an SOA record, it cannot be a zone apex that has sub-records, so no subdomains nor delegations are permitted. Even the recent RFC draft titled Let localhost be localhost is consistent with this.
https://myprefix.mycompany.localhost:1234
This should do the trick. Because localhost is a top-level-domain, it behaves like a .com in production code.
It took me a bit of time to find public wildcard DNS domains pointing to localhost so I'm leaving it here for future reference.
The domain that worked for me is localtest.me. That domain and its sub-domains resolve to 127.0.0.1 and ::1.
For example:
$ host localtest.me
localtest.me has address 127.0.0.1
localtest.me has IPv6 address ::1
$ host some-sub-domain.localtest.me
some-sub-domain.localtest.me has address 127.0.0.1
some-sub-domain.localtest.me has IPv6 address ::1
A maintained list of other public wildcard DNS domains that point to localhost can be found in this Gist.
From WSL in Windows:
First navigate to /mnt/c/Windows/System32/drivers/etc(Navigate cause, you may find more interesting files. Don't play here, but see what do they do)
Then do nano hosts(add at very bottom)
127.0.0.1 random.com
127.0.0.1 auth.random.com

netsh http add urlacl work like a local DNS?

I'm using netsh http add urlacl url=http://devsite1:80/ user=everyone as mentioned at http://www.hanselman.com/blog/WorkingWithSSLAtDevelopmentTimeIsEasierWithIISExpress.aspx to work with 80 and 443 SSL port, but web browser can't bind my http://devsite1 local address and them, nothing work.
Should be really have set line as 127.0.0.1 devsite1 at hosts file in Windows drive etc folder?
In this link above he said:
My machine is called HANSELMAN-W500, so I'll use that name. You could update your hosts file and use a friendly name. To start, use your computer name. if you don't know the name of your computer, you're silly. Go to the command prompt and type "HOSTNAME" to find out.

http://127.0.0.1 got redirected to http://10.114.5.20/

I have IIS installed in my local machine. When I have my IE settings to use a corporate proxy pac script, when I browse http://127.0.0.1 instead of going into my IIS it goes to http://10.114.5.20/. If I set my IE settings to a manual proxy (with the bypass proxy by local adress checked) the http://127.0.0.1 show my IIS application.
Any ideas what is wrong with the original settings? How 127.0.0.1 gets redirected to another IP? Where to look?
My computer is w7 64 bits laptop.
Don't know who is 10.114.5.20. It is not my local ip. It is not any of my dns servers. It is not my default gateway.
Pac script could return two proxies: or 10.114.5.11 or 10.114.5.14. Not sure what the 10.114.5.20 machine could be, maybe it is the default gateway of the proxies...
Just a last update:
I download and saved the PAC script locally, and changed the http://... URI to a local file://C:/... one. And surprisingly enough, it worked. I mean the http://localhost now goes to my computer, not to the strange http://10.114.5.20/.
Reading the PAC script file I notice that when opened with Notepad all text goes into one line, but opening with Wordpad I see several lines. Opening in binary, the carriage return is a unix style one (0A) instead of the windows one (0D0A).
So I supose the explanation comes down to say the Automatic configuration script setting in IE doesn't understand unix style carriage returns When parsing the pac script, so it always returned the proxy, never DIRECT.
The problem is in the corporate proxy pac script. It does not allow the "bypass proxy for local addresses".
Try ping -a 10.114.5.20 or tracert 10.114.5.20 to try to figure out who is at that address.
FYI... if you want to use the default settings for the proxy, then don't use "localhost", instead, use your real IP address. The Proxy server should redirect the request back to your own machine.
Sounds like corporate IT has an entry in your hosts file that's redirecting you.
Open Windows Explorer and browse to C:\Windows\System32\drivers\etc. Open the hosts file with Notepad or another text editor. Do you see an entry that directs http://127.0.0.1 somewhere else?
If so, commenting that out should fix the issue.

Resources