MPICH2 gethostbyname failed

biocyberman picture biocyberman · Apr 16, 2014 · Viewed 12.8k times · Source

I don't understand the error message. I am trying to do is to run a MPICH2 application after I installed mpich2 version 1.4 or 1.5 to /opt/mpich2 (both version failed with the same error). My MPI application was compiled with 1.3 but I am able to run it with mpi 1.4 on another workstation. I am testing it on Ubuntu 12.04.

Fatal error in PMPI_Init_thread: Other MPI error, error stack:
MPIR_Init_thread(467)..............: 
MPID_Init(177).....................: channel initialization failed
MPIDI_CH3_Init(70).................: 
MPID_nem_init(319).................: 
MPID_nem_tcp_init(171).............: 
MPID_nem_tcp_get_business_card(418): 
MPID_nem_tcp_init(377).............: gethostbyname failed, localhost (errno 3)

Answer

Mateusz Piotrowski picture Mateusz Piotrowski · Nov 6, 2016

Solution for macOS

I stumbled upon this issue on macOS 10.12.1.

The solution is to add 127.0.0.1 computername.local to /etc/hosts. Your file will look more or less like this:

##
# 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
127.0.0.1   computername.local
255.255.255.255 broadcasthost
::1             localhost 

You can change/check your computer's name if you go to System Preferences > Sharing > Computer Name.