title: Hadoop: java.net.ConnectException: Connection refused
body: <p>Hello I have been trying to follow this tutorial: <a href="http://www.tutorialspoint.com/apache_flume/fetching_twitter_data.htm" rel="nofollow">http://www.tutorialspoint.com/apache_flume/fetching_twitter_data.htm</a>
  for a very long time now and I am absolutely stuck at Step 3: Create a Directory in HDFS. I have ran start-dfs.sh and start-yarn.sh and both seem to have worked correctly as I am getting the same output as the tutorial but when I try to run:</p>
  
  <pre><code>hdfs dfs -mkdir hdfs://localhost:9000/user/Hadoop/twitter_data 
  </code></pre>
  
  <p>I keep receiving the same error: </p>
  
  <pre><code>mkdir: Call From trz-VirtualBox/10.0.2.15 to localhost:9000 failed on connection exception: java.net.ConnectException: Connection refused; For more details see:  http://wiki.apache.org/hadoop/ConnectionRefused
  </code></pre>
  
  <p>I can not figure out why as I have searched everywhere and tried a number of solutions but can't seem to make progress. I am going to list all of the files that I think could cause this but I could be wrong: My core.site.xml is:</p>
  
  <pre><code>&lt;configuration&gt;
  &lt;property&gt;  
  &lt;name&gt;hadoop.tmp.dir&lt;/name&gt;
  &lt;value&gt;/Public/hadoop-2.7.1/tmp&lt;/value&gt;
  &lt;description&gt;A base for other temporary directories.&lt;/description&gt;
  &lt;/property&gt;
  &lt;property&gt;
  &lt;name&gt;fs.default.name&lt;/name&gt;
  &lt;value&gt;hdfs://localhost:9000&lt;/value&gt;
  &lt;/property&gt;
  </code></pre>
  
  <p>My mapred-site.xml is:</p>
  
  <pre><code>&lt;configuration&gt;
  &lt;property&gt;
  &lt;name&gt;mapred.job.tracker&lt;/name&gt;
  &lt;value&gt;hdfs://localhost:9001&lt;/value&gt;
  &lt;/property&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>My hdfs.site.xml is:</p>
  
  <pre><code>&lt;configuration&gt;
  &lt;property&gt;
  &lt;name&gt;dfs.replication&lt;/name&gt;
  &lt;value&gt;1&lt;/value&gt;
  &lt;/property&gt;
  &lt;property&gt;
  &lt;name&gt;dfs.permission&lt;/name&gt;
  &lt;value&gt;false&lt;/value&gt;
  &lt;/property&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>I am running Ubuntu 14.04.4 LTS on virtual box. My ~/.bashrc looks as so:</p>
  
  <pre><code>export JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-amd64
  export HADOOP_HOME=/usr/local/hadoop/bin 
  export HADOOP_HOME=/usr/local/hadoop/bin
  export HADOOP_INSTALL=$HADOOP_HOME
  export HADOOP_MAPRED_HOME=$HADOOP_HOME
  export HADOOP_COMMON_HOME=$HADOOP_HOME
  export HADOOP_HDFS_HOME=$HADOOP_HOME
  export YARN_HOME=$HADOOP_HOME
  export HADOOP_COMMON_LIB_NATIVE_DIR=$HADOOP_HOME/lib/native
  export PATH=$PATH:$HADOOP_HOME/sbin:$HADOOP_HOME/bin
  #flume
  export FLUME_HOME=/usr/local/Flume
  export PATH=$PATH:/FLUME_HOME/apache-flume-1.6.0-bin/bin
  export CLASSPATH=$CLASSPATH:/FLUME_HOME/apache-flume-1.6.0-bin/lib/*
  </code></pre>
  
  <p>And finally my /etc/hosts file is set up as so:</p>
  
  <pre><code>127.0.0.1  localhost
  10.0.2.15  trz-VirtualBox
  10.0.2.15  hadoopmaster
  
  
  # 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
  </code></pre>
  
  <p>The added hadoopmaster I am currently not using, that was one of my attempts to fix this by trying not to use local host (didn't work). trz-VirtualBox was originally 127.0.1.1 but I read that you should use your real IP address? Neither worked so I am not sure. I posted all of these files because I do not know where the error is. I do not think it is a path issue (I had a lot before I got to this step and was able to resolve them myself) so I am out of ideas. I've been at this for a number of hours now so any help is appreciated. Thank you. </p>