[Solved] RLException: Unable to contact my own server

Hello,

I am trying to install ROS on ubuntu 18.04 using this tutorial (How to Install ROS on Ubuntu 18.04 - The Construct). After following the tutorial, I tried to run roscore but I run into the error:

RLException: Unable to contact my own server at [http://localhost:65431/].
This usually means that the network is not configured properly.

A common cause is that the machine cannot connect to itself.  Please check
for errors by running:

        ping localhost

For more tips, please see

        http://wiki.ros.org/ROS/NetworkSetup

The traceback for the exception was written to the log file

I may have messed up some files when I was trying to install husarnet. The bottom of my .bashrc looks like this:

export PATH="/home/musicboy/anaconda3/bin:$PATH"
source /opt/ros/melodic/setup.bash
export ROS_HOSTNAME=localhost
export ROS_MASTER_URI=http://localhost:11311
export ROS_IPV6=on

And my /etc/hosts looks like this:

# This file was automatically generated by WSL. To stop automatic generation of this file, add the following $# [network]
# generateHosts = false
127.0.0.1       localhost
127.0.1.1       LAPTOP-E7I1REEH.localdomain     LAPTOP-E7I1REEH

# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

I am unsure how to proceed from here. I would like to install ROS on my computer so that I may run gazebo on it, but it seems that one of my settings is incorrect. I have tried uninstalling and reinstalling ROS, would anyone know what the problem is? Please let me know if you need any more information, I’d appreciate any help!

Hi musicboy,

After installing husarnet your dafult hostname changes from localhost to one specified for husarnet - LAPTOP-E7I1REEH in you case. Changing it in ROS_HOSTNAME or simply removing this line from .bashrc should solve your problem.

Regards,
Dawid