Can't access 127.0.0.1 apache 2 (MacOS X) - macos

After my MacBook Pro mid2009 has been updated to MacOS X El Capitan I found that many things don't work anymore as they were before.
Built-in apache2 is not aviable on http://127.0.0.1 but aviable on http://localhost. In Yosemite both of them was working properly.
/private/etc/hosts looks like that:
##
# 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
It's looks strange cuz 127.0.0.1 and localhost are the same thing.
Any idea what's going on?
httpd.conf
#
# Listen: Allows you to bind Apache to specific IP addresses and/or
# ports, instead of the default. See also the <VirtualHost>
# directive.
#
# Change this to Listen on specific IP addresses as shown below to
# prevent Apache from glomming onto all bound IP addresses.
#
#Listen 12.34.56.78:80
Listen 80

In your httpd.conf, you will have a Listen directive, this will be the ip address / port that the server will bind to.
In your conf file you have defined
Listen 80
That is stating that you should bind to all interfaces on port 80, this will include both IPv4, and IPv6;
Disabling IPv6 should would, change this line to
# allow access on all interfaces
Listen 0.0.0.0:80
# or for local access only
# Listen 127.0.0.1:80
# or more specifically
# Listen 192.168.0.0:80
# To listen on a specific subnet
To figure out why the site will not load when accessed via IPv6, would require additional error / debug logs.

Related

Mac won't connect to localhost server run from VirtualBox

My mac won't connect to localhost, I've tried with Safari and Mozilla, so it's not the browser, I tried other solutions I found on the internet, I ping 127.0.0.1 and it works correctly, if I run dscacheutil -q host -a name localhost I get the following:
name: localhost
ipv6_address: ::1
name: localhost
ip_address: 127.0.0.1
If I run apachectl configtest I get Syntax OK.
I've also read that my /etc/hosts might have been corrupted, this is how it looks like:
##
# 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
# Added by Docker Desktop
# To allow the same kube context to work on the host and the container:
127.0.0.1 kubernetes.docker.internal
# End of section
I have no idea what else to try
EDIT: I'm trying to run an application (Hortonworks Sandbox) from a virtual machine (VirtualBox) in mac, I was advised to try port forwarding but this is what I see when I check the port forwarding in VirtualBox, seems like everything is in order:
I also tried to run Vagrant from VirtualBox and Mac couldn't connect to the localhost server when needed

This address: 127.0.0.1:5000 on Mac Catalina not working (docker) but working on Windows

This address: 127.0.0.1:5000 on Mac Catalina not working (docker) but working on Windows.
Question:
How do I get access to port:5000 working on my MAC?
# 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
# Added by Docker Desktop
# To allow the same kube context to work on the host and the
container: 127.0.0.1 kubernetes.docker.internal
# End of section
Update the line ## 127.0.0.1 localhost to 127.0.0.1 localhost in your /etc/hosts file.
Basically # is used for commenting in bash.
After that, you will be able to access using 127.0.0.1:5000 and http://localhost:5000

MacOS doesn't resolve localhost to 127.0.0.1 (ignores hosts / apache vhosts)

I ran into the problem, that localhost redirects to a specific domain instead of 127.0.0.1.
My configuration is a local apache/mysql/php installation on MacOS Mojave using vhosts for different projects that are configured in hosts to redirect properly.
When I enter 127.0.0.1 in any browser, I get to my overview page lying in the www root. The same should happen, when I enter localhost in the browser, but instead it redirects to a domain of a project I was working on in the past. It happens also without network connection, so the configuration is on this machine.
My /etc/hosts file:
##
# 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 project1.local project2.local
255.255.255.255 broadcasthost
::1 localhost
fe80::1%lo0 localhost
The first line seems to be ignored and localhost doesn't resolve to 127.0.0.1.
I only have two vhost configurations plus default configuration with no wrong redirection and also the httpd.conf lookes fine. I searched the whole machine with grep -lr "redirectiondomain.com" * without results. I tried with apache switched off with the same result and looked up the MacOS network settings but I can't find anything related to the wrong redirection neither any other solution on stackoverflow or google that solves my issue. Has anybody a clue how the wrong redirection of localhost could be set somewhere else?
Edit: My hostname in MacOS is set. I tried localhost without port, with :80 and :8080

gethostbyname fail after switching internet connections

I often (but not always) get the following error when running MPI jobs after switching wifi hosts.
Fatal error in MPI_Init: Other MPI error, error stack:
MPIR_Init_thread(498)..............:
MPID_Init(187).....................: channel initialization failed
MPIDI_CH3_Init(89).................:
MPID_nem_init(320).................:
MPID_nem_tcp_init(171).............:
MPID_nem_tcp_get_business_card(418):
MPID_nem_tcp_init(377).............: gethostbyname failed, MacBook-Pro.local (errno 1)
Everything works fine in the coffee shop, and then when I come home, I get the above error. Nothing else has changed.
I've checked the /etc/hosts and /private/etc/hosts files, and they look okay -
##
# 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
I can ping localhost, so the problem isn't exactly that localhost isn't resolved.
Rebooting always fixes the problem, but is there something simple I can do to "reset" my system so that it recognizes local host?
I don't have access to the details of the MPI initialization routines in the code I am running and am not making any explicit calls to gethostname.
I am using MPICH 3.1.4 (built Feb, 2015) and am running OSX 10.10.3
The answer is very simple - here is what seems to work.
I edited the file /etc/hosts (or /private/etc/hosts, in OSX) and added the line
127.0.0.1 macbook-pro.local
so now my hosts files looks like :
##
# 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
127.0.0.1 macbook-pro.local
We were facing this issue intermittently on our CI server. It seems that setting the environment variable MPICH_INTERFACE_HOSTNAME to localhost helped.

How do I change the IP address in XAMPP for Windows?

I've been trying to figure out how I can change my server config for XAMPP so that it doesn't have a memory fault when both Windows and the server are trying to access localhost at the same time. Basically I want XAMPP to be IP of 127.0.1.1 or something similar so it doesn't interfere with the localhost used by the system so I can browse the web and my websites that I'm developing. What is happening is that if I have XAMPP and Eversoft's first page 2000 v2.0 running at the same time, I'll get a BSOD (blue screen of death) in the middle of editing my sites. This is an intermittent problem, but always happens with these two programs.
Just edit c:\xampp\apache\conf\httpd.conf and change the Listen 80 to Listen 127.0.0.2:80 or whatever ip address you want. Make sure you place : between the ip address and port number, in this case it was port 80.
These are the steps to follow when you want your PHP application to be installed on a LAN server (not on web)
Get the internal IP or Static IP of the server (Ex: 192.168.1.193)
Open XAMPP>apache>conf>httpd.conf file in notepad
Search for Listen 80
Above line would read like- #Listen 0.0.0.0:80 / 12.34.56.78:80
Change the IP address and replace it with the static IP
Save the httpd.conf file ensuring that the server is pointed to #Listen 192.168.1.193:80
In the application root config.php (db connection) replace localhost with IP address of the server
Note: If firewall is installed, ensure that you add the http port 80 and 8080 to exceptions and allow to listen. Go to Control Panel>Windows Firewall>Allow a program to communicate through windows firewall>Add another program Name: http Port: 80 Add one more as http - 8080
If IIS (Microsoft .Net Application Internet Information Server) is installed with any Microsoft .Net application already on server, then it would have already occupied 80 port. In that case change the #Listen 192.168.1.193:80 to #Listen 192.168.1.193:8080
Hint:
first part=file location --- second part=find in the file ---
third part=replace with finded text
How Change "127.0.0.1" in Xampp To "127.0.0.2" (or paste your favorite ip instead 127.0.0.2)
(C:\xampp\apache\conf\httpd.conf) --- Listen 80 --- Listen 127.0.0.2:80
(C:\xampp\apache\conf\extra\httpd-ssl.conf) --- Listen 443 --- Listen 127.0.0.2:443
(C:\xampp\php\php.ini) --- ;xdebug.remote_host = "127.0.0.1" --- ;xdebug.remote_host = "127.0.0.2"
(C:\xampp\phpMyAdmin\config.inc.php) --- $cfg['Servers'][$i]['host'] = '127.0.0.1'; --- $cfg['Servers'][$i]['host'] = '127.0.0.2';
How Change "Localhost" in Xampp To "myhost" (or paste your favorite name instead myhost)
xampp control panel admin butoons still open localhost
(C:\xampp\apache\conf\httpd.conf) --- ServerName localhost:80 --- ServerName myhost:80
(C:\xampp\php\php.ini) --- ; SMTP = localhost --- ; SMTP = myhost
(C:\Windows\System32\drivers\etc\HOSTS) --- 127.0.0.1 localhost --- 127.0.0.2 localhost
127.0.0.2 myhost >>> #(next line after 127.0.0.2 localhost)
You can point 127.0.1.1 to 127.0.0.1 in your windows hosts file (Windows/system32/driver/etc)

Resources