ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

roslaunch erros out when trying to launch master when master is already running via roscore

asked 2017-07-31 23:17:46 -0600

roy gravatar image

updated 2017-08-01 01:09:27 -0600

gvdhoorn gravatar image


I am having this issue where I can't use roslaunch command because every time I run something like:

roslaunch ros_robotics ddrobot_rviz.launch model:=dd_robot.urdf

it will error out with following message:

started roslaunch server http://localhost:34665/


 * /joint_state_publisher/use_gui: True
 * /robot_description: <?xml version="1....
 * /rosdistro: kinetic
 * /rosversion: 1.12.7

    joint_state_publisher (joint_state_publisher/joint_state_publisher)
    robot_state_publisher (robot_state_publisher/state_publisher)
    rviz (rviz/rviz)

auto-starting new master
process[master]: started with pid [2401]
ERROR: Unable to start XML-RPC server, port 11311 is already in use
Unhandled exception in thread started by <bound method of <rosgraph.xmlrpc.XmlRpcNode object at 0x7f38a45133d0>>
Traceback (most recent call last):
  File "/opt/ros/kinetic/lib/python2.7/dist-packages/rosgraph/", line 215, in run
  File "/opt/ros/kinetic/lib/python2.7/dist-packages/rosgraph/", line 284, in _run
  File "/opt/ros/kinetic/lib/python2.7/dist-packages/rosgraph/", line 234, in _run_init
    self.server = ThreadingXMLRPCServer((bind_address, port), log_requests)
  File "/opt/ros/kinetic/lib/python2.7/dist-packages/rosgraph/", line 115, in __init__
    SimpleXMLRPCServer.__init__(self, addr, SilenceableXMLRPCRequestHandler, log_requests)
  File "/usr/lib/python2.7/", line 593, in __init__
    SocketServer.TCPServer.__init__(self, addr, requestHandler, bind_and_activate)
  File "/usr/lib/python2.7/", line 417, in __init__
  File "/usr/lib/python2.7/", line 431, in server_bind
  File "/usr/lib/python2.7/", line 228, in meth
    return getattr(self._sock,name)(*args)
socket.error: [Errno 98] Address already in use
ERROR: could not contact master [http://localhost:11311//]
The traceback for the exception was written to the log file
[master] killing on exit

It seems that roslaunch tries to launch a master server while there is already one running in another terminal window.

Any idea how to resolve this?


As requested, this launch file might be helpful. That said, this issue is not specific to this particular launch file. Every launch file on my system errors out like this.

  <!-- set parameter on Parameter Server -->
  <arg name="model" />
  <param name="robot_description"
    command="$(find xacro)/ '$(find ros_robotics)/urdf/$(arg model)'" />

  <!-- send joint values from gui -->
  <node name="joint_state_publisher" pkg="joint_state_publisher" type="joint_state_publisher">
    <param name="use_gui" value="TRUE"/>

  <!-- use joint positions to update tf -->
  <node name="robot_state_publisher" pkg="robot_state_publisher" type="state_publisher"/>

  <!-- visualize robot model in 3D -->
  <node name="rviz" pkg="rviz" type="rviz" args="-d $(find ros_robotics)/urdf.rviz" required="true" />



Edit: @gvdhoorn

 roy@RoysMacUbuntu:~/catkin_ws/src/ros_robotics/urdf$ printenv | grep ROS
edit retag flag offensive close merge delete


I might not be able to help much, but if you can post the roslaunch files in question (or links to them) that will definitely help others debug the issue.

M@t gravatar image M@t  ( 2017-07-31 23:47:12 -0600 )edit

@roy: could you also add the values of ROS_MASTER_URI, ROS_IP and ROS_HOSTNAME?

gvdhoorn gravatar image gvdhoorn  ( 2017-08-01 00:48:59 -0600 )edit

It probably shouldn't matter, but can you remove the two forward-slashes (/) at the end of ROS_MASTER_URI and try again?

gvdhoorn gravatar image gvdhoorn  ( 2017-08-01 01:07:41 -0600 )edit

ROS_IP is empty for some reason. Do I need to set this somewhere?

roy gravatar image roy  ( 2017-08-01 01:08:50 -0600 )edit

ROS_IP is only needed if you don't have a working DNS for all involved hosts. If you're not running a multi-host ROS setup -- and localhost resolves to the proper IP -- then it's not needed.

gvdhoorn gravatar image gvdhoorn  ( 2017-08-01 01:10:35 -0600 )edit

Where does the source suffix on ROS_HOSTNAME come from?

Are you setting any of these variables yourself -- in your .bashrc fi?

gvdhoorn gravatar image gvdhoorn  ( 2017-08-01 01:11:09 -0600 )edit

Here are ROS related lines in my.bashrc: source /opt/ros/kinetic/setup.bash source ~/catkin_ws/devel/setup.bash

export ROS_MASTER_URI=http://localhost:11311// export ROS_HOSTNAME=localhostsource /opt/ros/kinetic/setup.bash

roy gravatar image roy  ( 2017-08-01 01:13:37 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2017-08-01 01:17:40 -0600

gvdhoorn gravatar image

Here are ROS related lines in my .bashrc:

source /opt/ros/kinetic/setup.bash
source ~/catkin_ws/devel/setup.bash

export ROS_MASTER_URI=http://localhost:11311//
export ROS_HOSTNAME=localhostsource /opt/ros/kinetic/setup.bash

If that is really a copy-paste of your .bashrc then it would seem something went wrong while adding those lines (there was most likely a new-line missing after the export ROS_HOSTNAME line).

If you don't have a particular reason to set ROS_MASTER_URI and ROS_HOSTNAME to those values (localhost is already the default), then I would recommend to remove the export .. lines from your .bashrc, save it, open a new terminal and try starting your launch file again.

So your .bashrc should look like this (at the end, after all the normal stuff that is already there):

source /opt/ros/kinetic/setup.bash
source ~/catkin_ws/devel/setup.bash
edit flag offensive delete link more


Awesome, it worked. Although the error messages printed out doesn't seem to be very relevant to the issue.

Thank you very much!

roy gravatar image roy  ( 2017-08-01 01:21:40 -0600 )edit

Well, in a way the error message tells you that it can't connect to any -- already running -- master instance. That is true, as the env vars that influence the network config of ROS were incorrectly set. If it can't find a running master, roslaunch will start one itself. But as there already was one running, it ran into a socket.error: [Errno 98] Address already in use error (which makes sense).

I think the fact that ROS_MASTER_URI was set to localhost:11311// (notice the two forward-slashes) also didn't help.

gvdhoorn gravatar image gvdhoorn  ( 2017-08-01 01:23:48 -0600 )edit

I was facing the same problem. I removed the export.. things from my .bashrc after seeing your answer and it worked. Thank you for your suggestion.

Milin gravatar image Milin  ( 2020-04-17 13:52:18 -0600 )edit

Question Tools


Asked: 2017-07-31 23:17:46 -0600

Seen: 6,078 times

Last updated: Aug 01 '17