-1

I'm trying to connect to port 8020 on a CentOS vm but I'm getting telnet: connect to address <public_ip>: Connection refused when I run telnet public_ip 8020. When I run netstat -anp | grep 8020 I get

tcp        0      0 127.0.0.1:8020              0.0.0.0:*                   LISTEN      18908/java
tcp        0      0 127.0.0.1:38750             127.0.0.1:8020              TIME_WAIT   -

I have other ports listening, telnet public_ip 50070 allows me to connect. The output for netstat on that is

tcp        0      0 0.0.0.0:50070               0.0.0.0:*                   LISTEN      18908/java

When I execute telnet localhost 8020 I get

Trying ::1...
telnet: connect to address ::1: Connection refused
Trying 127.0.0.1...
Connected to localhost.

Do I need to do something to change the 127.0.0.1 in the netstat for 8020 to 0.0.0.0 like it is for the successful connection to 50070?

The output of iptables -L -v is

Chain INPUT (policy ACCEPT 84481 packets, 11M bytes)
 pkts bytes target     prot opt in     out     source               destination

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination

Chain OUTPUT (policy ACCEPT 54190 packets, 6770K bytes)
 pkts bytes target     prot opt in     out     source               destination

This is a hadoop service, the config that tells it to listen on port 8020 is in core-site.xml

<property>
    <name>fs.defaultFS</name>
    <value>hdfs://localhost:8020</value>
</property>
gary69
  • 119
  • 1
  • 7
  • what's the downvote for? – gary69 Feb 01 '16 at 23:07
  • What is listening on port 8020? – David Schwartz Feb 01 '16 at 23:12
  • hadoop, the port accessible through hdfs – gary69 Feb 01 '16 at 23:14
  • Show us the hadoop config the causes the port to be listened on. – David Schwartz Feb 01 '16 at 23:15
  • I changed the config to use my public ip instead of localhost and it worked – gary69 Feb 01 '16 at 23:29
  • Please post the output of IPTables -L -v If the service/application listening to 8020 needs to be accessible outside the box itself, then you probably want to change the config of the service in question to listen to 0.0.0.0 – Joe Feb 01 '16 at 23:04
  • how do I do that? – gary69 Feb 01 '16 at 23:10
  • Possible duplicate of [What causes the 'Connection Refused' message?](http://serverfault.com/questions/725262/what-causes-the-connection-refused-message) – kasperd Feb 05 '16 at 10:30
  • I don't think this is a duplicate of http://serverfault.com/questions/725262/what-causes-the-connection-refused-message. Yes this is the same general problem but the answer is extremely general and cites the two causes as nothing listening on the port and a firewall. I was using the correct port, the problem was I was using an incorrect alias for my server that didn't allow other servers on the network to find it. I stated in the question that I was able to connect from the remote server and that there was a service listening on that port. – gary69 Feb 05 '16 at 16:52

1 Answers1

3
<property>
    <name>fs.defaultFS</name>
    <value>hdfs://localhost:8020</value>
</property>

You told it to bind to localhost. That's not a good idea if you want it to be accessible from other machines.

David Schwartz
  • 31,449
  • 2
  • 55
  • 84