ROS Resources: Documentation | Support | Discussion Forum | Service Status | Q&A
Ask Your Question

How to solve "Couldn't find an AF_INET address for " problem

asked 2014-05-10 14:55:19 -0500

skyhawk gravatar image

updated 2017-09-26 14:26:04 -0500

130s gravatar image

Hi, I am running four computers with only one the ROS master, and I am sure I set the correct ROS_MASTER_URI (= to the other three computers. Then the problems like this: I run a node in the master computer, and also I publish some message to that node. In this master computer, I can use "rostopic echo" to see the published messages, but in another computer, if I run "rostopic list", I see all the topics, but if I run "rostopic echo /xxxx" then I cannot see anything. Most importantly, I see the master computer threw out a message saying Couldn't find an AF_INET address for [msl]. It is probably some network problem, so please help.

edit retag flag offensive close merge delete

9 Answers

Sort by » oldest newest most voted

answered 2014-07-30 14:25:05 -0500

mattc12345 gravatar image

skyhawk is right, set the ROS_IP for each computer. So for each computer, find the IP address in a terminal with

hostname -I

It will be the first set of numbers, like To set it,

export ROS_IP=

Make sure you're exporting the right address on each one, it'll be different for each computer.

edit flag offensive delete link more

answered 2014-05-10 15:37:35 -0500

skyhawk gravatar image

You should set the ROS_IP for each computer that is in the network running the ROS.

edit flag offensive delete link more

answered 2015-03-17 05:43:30 -0500

dim_sgou gravatar image

The only solution that worked for me was to list the ip address of each computer along with its hostname to the /etc/hosts file.

edit flag offensive delete link more


Thank you! In my case, having two ip address on the robot and two on the workstation, this was the only one working solution!

pulver gravatar imagepulver ( 2015-06-08 11:41:09 -0500 )edit

answered 2014-09-04 02:42:09 -0500

destogl gravatar image

Or just set on every computer in you network (so you don't have to thing about addresses):

export ROS_IP=`hostname -I`

Or even, sometimes better, solution is to add this line in your .bashrc file.

edit flag offensive delete link more



Be warned - this only works if your computer only has one IP address. If you have two addresses, perhaps ethernet and WiFi, hostname -I will show multiple addresses and your ROS_IP will probably be invalid.

ahendrix gravatar imageahendrix ( 2014-09-04 02:57:53 -0500 )edit

@ahendrix In the case of multiple addresses, what address do have to set ROS_IP to? I set it to the one which used for communication between host and the ROS PC but it did not work.

cellard0or gravatar imagecellard0or ( 2016-08-03 09:45:12 -0500 )edit

@cellard0or : that approach should work, but you've given very little information. Please ask a new question with details about your setup and the errors you're encountering.

ahendrix gravatar imageahendrix ( 2016-08-03 11:24:32 -0500 )edit

as current ubuntu revisions seem to report more than just the ip when calling hostname -I I used

machine_ip=(`hostname -I`)
export ROS_IP=${machine_ip[0]}
blubbi321 gravatar imageblubbi321 ( 2017-11-01 09:15:03 -0500 )edit

answered 2016-09-11 03:12:04 -0500

TifferPelode gravatar image

I found a way, change your /etc/hosts Such as:

vim /etc/hosts

then add your ip:   my_hostname
edit flag offensive delete link more


This was the only thing that worked for me after adding ROS_IP

kotoko gravatar imagekotoko ( 2018-08-06 06:08:41 -0500 )edit

answered 2016-01-13 16:47:14 -0500

Farid gravatar image

I would say the best answer... worked 100% for my robot and local computers. have a look...

edit flag offensive delete link more

answered 2015-11-19 12:30:46 -0500 gravatar image

If this is coming from a gazebo plugin -- it may be because gazebo is beignn run standalone rather than launched from ros as required.

edit flag offensive delete link more

answered 2015-11-20 05:15:24 -0500

cyborg-x1 gravatar image

Deluxe Version for Bash with multiple interfaces

function set_rosip
  RED="$(tput setb 4)"
  GREEN="$(tput setaf 0)$(tput setb 2)"
  BOLD=$(tput bold)
  NOCOLOR=$(tput sgr0)

  ifconfig $1
  } &> /dev/null

  if [ $? -ne 0 ]; then
    echo -e "${RED}Interface ${BOLD}$1${NOCOLOR}${RED} not found! ${BOLD}ROS_IP not set!${NOCOLOR}"
    return 1

  ip_addr=`ifconfig $1 | grep 'inet addr:' | cut -d: -f2 | awk '{print $1}'`

  if [ -z "$ip_addr" ]; then
    if [ "$3" == "1" ]; then
      echo -e "${RED}Interface ${BOLD}$1${NOCOLOR}${RED} not connected, ${BOLD}ROS_IP not set!${NOCOLOR}"
    return 1

  if [ "$2" == "1" ]; then
    echo ${GREEN}ROS_IP set to $1 with IP $ip_addr${NOCOLOR}

  export ROS_IP=$ip_addr
#Tries to get setup ROS_IP in the specified order and stops on the first success ... 
set_rosip wlan0 1 0 || set_rosip eth0 1 1 \
# ||  set_rosip ${anotherinterface} ${printonsuccess} ${printonfail}

If you want only be notified if the last one fails:

set_rosip wlan0 0 0 || set_rosip eth0 0 1
edit flag offensive delete link more

answered 2016-12-14 06:52:47 -0500

yucelokan gravatar image


I had same problem while ı am trying the upper link. I resolved, resolve is here.

open the .bashrc files and add this code.

You'll see those things like that:

export ROS_MASTER_URI=http://localhost (or something like that which is not your ip):11311
export ROS_HOSTNAME=(your machine name)

and you must change it like that:


change your ip adress.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools



Asked: 2014-05-10 14:55:19 -0500

Seen: 46,150 times

Last updated: Sep 26 '17