How to access localhost by IP address? [closed]
I am trying to access localhost by my IP address. My IP address is/was 217.164.79.62
(It is set to be automatically assigned so it keeps changing).
When I visit http://localhost/
, I get the XAMPP homepage.
However, when I visit http://217.164.79.62/
, I get the following message:
The server 217.164.79.62:80 requires a username and password.
User Name:
Password:
How do I get the username and password?
Solution 1:
To access the server from itself, use http://localhost/
or http://127.0.0.1/
.
To access the server from a separate computer on the same network, use http://192.168.X.X
where X.X
is your server's local IP address. You can find the sever's local IP address (assuming it's Linux) by running hostname -I
.
Solution 2:
http://localhost
is NOT the same as http://217.164.79.62
The localhost
address is 99.999% of the time mapped to the IP address 127.0.0.1
and is totally inaccessible from anywhere except your local machine
What you're finding when you're entering http://217.164.79.62
is that your modem/router device owns that IP address, so you're getting the login screen for it.
Solution 3:
Do you have a Modem/router type device to connect to the internet? It sounds like you are connecting to the configuration interface for this.
Alternatively: On what platform do you use XAMPP? Could you post the output of ipconfig in Windows or sudo ifconfig in Linux/MacOS?
--- Edit
OK, so with the info you gave here, it is now clear what the problem is (and that this belongs on superuser.com instead of Serverfault).
When you try to connect to your public IP address, you are in fact reaching your router, not your XP box. If you really would want to connect to the XAMPP server with this public IP address, you would need to configure your router to forward port 80 to your XP machine so that it is accessible from the outside (you will find how that is done in the routers documentation). However, this is a terrible idea if you just want to test things and don't need others to access it. Instead, you would either use 127.0.0.1
, which would only work on your XP box, or 192.168.254.4
, which would be accessible from any computer in your home LAN.
Could you edit your original question and tell us why you want to use the IP address instead of http://localhost
in the first place?
NB: The info you gave on the router/modem stated that it's firewall is deactivated. This is normally a really bad idea, I would strongly recommend turning it on. How this is done will also be explained in the documentation.
Solution 4:
It sounds like you are trying to connect to your modem. That means you haven't configured in your modem for your static IP...if you don't have a static IP, you can't route to port 80 with this IP address...and this shows, you can't log in to localhost with this ip...use 127.0.0.1 to connect localhost instead of this, if you don't have a static IP and if you haven't configured your router...