I know that many people ask this question but I try many path solution but any one was correct.
So, I have problem with connect to my postgresql server(on CentOS 6.4 minimal version - I have there only postgresql server, ftp and ssh service) from remote client(in LAN). I have ssh connection so I think that problem can by with permission tcp/ip.
Java throw exception:
org.postgresql.util.PSQLException: Connection refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.
at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:207)
at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:64)
at org.postgresql.jdbc2.AbstractJdbc2Connection.<init>(AbstractJdbc2Connection.java:136)
at org.postgresql.jdbc3.AbstractJdbc3Connection.<init>(AbstractJdbc3Connection.java:29)
at org.postgresql.jdbc3g.AbstractJdbc3gConnection.<init>(AbstractJdbc3gConnection.java:21)
at org.postgresql.jdbc4.AbstractJdbc4Connection.<init>(AbstractJdbc4Connection.java:31)
at org.postgresql.jdbc4.Jdbc4Connection.<init>(Jdbc4Connection.java:24)
at org.postgresql.Driver.makeConnection(Driver.java:393)
at org.postgresql.Driver.connect(Driver.java:267)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at Main.main(Main.java:19)
Caused by: java.net.ConnectException: Connection timed out: connect
at java.net.DualStackPlainSocketImpl.connect0(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at org.postgresql.core.PGStream.<init>(PGStream.java:60)
at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:101)
... 11 more
ifconfig:
eth0 Link encap:Ethernet HWaddr 08:00:27:F0:3A:F4
inet addr:192.168.1.18 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fef0:3af4/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:2677 errors:0 dropped:0 overruns:0 frame:0
TX packets:1437 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:251266 (245.3 KiB) TX bytes:214910 (209.8 KiB)
/var/lib/pgsql/9.2/data/pg_hba.conf - only main part of file
# "local" is for Unix domain socket connections only
local all all peer
# IPv4 local connections:
host all all 127.0.0.1/32 ident
host all all 192.168.1.18 255.255.255.0 password
#hostssl all all 192.168.1.18 255.255.255.0 trust
#hostnossl all all 192.168.1.18 255.255.255.0 trust
# IPv6 local connections:
host all all ::1/128 ident
# Allow replication connections from localhost, by a user with the
# replication privilege.
#local replication postgres peer
#host replication postgres 127.0.0.1/32 ident
#host replication postgres ::1/128 ident
host all all 192.168.1.18 255.255.255.255 password
host all all ::1 ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff password
var/lib/pgsql/9.2/data/poistgresql.conf - only main part
# - Connection Settings -
listen_addresses = '*'
#'localhost,192.168.1.18'
# what IP address(es) to listen on;
# comma-separated list of addresses;
# defaults to 'localhost'; use '*' for all
# (change requires restart)
#port = 5432 # (change requires restart)
max_connections = 100 # (change requires restart)
# Note: Increasing max_connections costs ~400 bytes of shared memory per
# connection slot, plus lock space (see max_locks_per_transaction).
#superuser_reserved_connections = 3 # (change requires restart)
#unix_socket_directory = '' # (change requires restart)
#unix_socket_group = '' # (change requires restart)
#unix_socket_permissions = 0777 # begin with 0 to use octal notation
# (change requires restart)
#bonjour = off # advertise server via Bonjour
# (change requires restart)
and last debug info is comment netstat -ta
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 *:ssh *:* LISTEN
tcp 0 0 *:postgres *:* LISTEN
tcp 0 0 localhost:smtp *:* LISTEN
tcp 0 52 PC2.home:ssh Michal-laptop.home:26146 ESTABLISHED
tcp 0 0 PC2.home:ssh Michal-laptop.home:25917 ESTABLISHED
tcp 0 0 *:ssh *:* LISTEN
tcp 0 0 *:postgres *:* LISTEN
tcp 0 0 localhost:smtp *:* LISTEN
Can you help my? what I should do to allow connection?
Thank you for your time.
As you cannot telnet to your server port 5432, you are going to have to open port 5432 in the firewall.
Think it's something like System -> Administration -> Firewall or /usr/bin/system-config-firewall through the console.
In var/lib/pgsql/9.2/data/poistgresql.conf
Uncomment below line:
#port = 5432
You can change listening port if you want. Restart the service.
Related
I want to run a simple Spring Boot application on my Ubuntu 16.04.6 x64 droplet. To allow incoming connections I had to open the 8080 port, since this is where the embedded tomcat server in the spring boot jar will listen for connections.
I used the ufw allow 8080 command and now I see this on me droplet.
#ufw status
Status: active
To Action From
-- ------ ----
8080 ALLOW Anywhere
22 ALLOW Anywhere
80 ALLOW Anywhere
8080 (v6) ALLOW Anywhere (v6)
22 (v6) ALLOW Anywhere (v6)
80 (v6) ALLOW Anywhere (v6)
I made sure I have my application running:
java -jar myservice.jar &
Netstat reports that something is listening on 8080:
# netstat -aon
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State Timer
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN off (0.00/0/0)
tcp 0 XXX XX.XXX.XX.XXX:22 XX.XX.XXX.XX:64021 ESTABLISHED on (0.11/0/0)
tcp6 0 0 :::8080 :::* LISTEN off (0.00/0/0)
tcp6 0 0 :::22 :::* LISTEN off (0.00/0/0)
Yet when I do telnet outside the server I get:
telnet XX.XXX.XX.XXX 8080
Connecting To XX.XXX.XX.XXX...Could not open connection to the host, on port 8080: Connect failed
And when I do telnet on the server I get:
# telnet localhost 8080
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
In Digital Ocean's Firewall control panel I have the following setup:
HTTP requests to the server just hang and never return. They don't even reach the tomcat server, judging by the lack of logs.
What am I missing? Any suggestions would be really appreciated!
UPDATE 1:
Local (inside the server) curl requests to my healthcheck endpoint were also hanging. However I left one for longer period and I got this application log:
2019-05-13 18:39:48.723 WARN 5873 --- [nio-8080-exec-2] o.a.c.util.SessionIdGeneratorBase : Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [214,287] milliseconds.
This explained why the request was hanging, so applying the answer from this post fixed that. Now I'm able to hit my endpoint on the server and it's responding.
However outside the box, requests are still not making it to the server. Telnet outside still says Could not open connection to the host, on port 8080.
I'm not 100% sure why, but the Firewall rules from the Digital Ocean Firewall Control panel were interfering with my droplet configuration.
I've deleted the Firewall rules from the control panel and now netstat reports that my 8080 port is open and I'm able to talk to the server from the outside world, finally.
#nmap -sS -O XX.XXX.XX.XXX
Starting Nmap 7.01 ( https://nmap.org ) at 2019-05-13 21:13 UTC
Nmap scan report for myservice (XX.XXX.XX.XXX)
Host is up (0.000024s latency).
Not shown: 998 closed ports
PORT STATE SERVICE
22/tcp open ssh
8080/tcp open http-proxy
Device type: general purpose
Running: Linux 3.X
OS CPE: cpe:/o:linux:linux_kernel:3
OS details: Linux 3.8 - 3.19
Network Distance: 0 hops
Also check UPDATE 1 from the question as it was also causing bizarre confusion.
I'm using sockets for a client-server application (i.e. the client sends data and the server received the data). My code is below. When I use the client in an Android 5.1 application on a tablet and the server in a Java application on a Windows 7 PC it works very well (i.e. the tablet can send data to the PC). But when I try to use the server code on the Android 5.1 application on the tablet and the client code on the PC (i.e. sending data from the PC to the tablet) the connection cannot be established and I'm getting the error:
java.net.ConnectException: Connection timed out: connect
The tablet and the PC are in the same network.
What is wrong?
Server:
ServerSocket ss = new ServerSocket(13005);
Socket socket = ss.accept();
ObjectInputStream is = new ObjectInputStream(new BufferedInputStream(socket.getInputStream()));
Client:
socket = new Socket();
socket.connect(new InetSocketAddress("10.2.130.125", 13005));
oos = new ObjectOutputStream(new BufferedOutputStream(socket.getOutputStream()));
Edit:
I have now executed netstat -nap. The output is as follows (I have altered the foreign addresses slightly). 13005 seems not to be used.
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 417 0 10.2.130.125:36844 xxx.xxx.23.74:443 CLOSE_WAIT
tcp 417 0 10.2.130.125:35996 xxx.xxx.23.110:443 CLOSE_WAIT
tcp6 1 0 ::ffff:10.2.130.125:44994 ::ffff:xxx.xx.205.170:443 CLOSE_WA
IT
tcp6 0 0 ::ffff:10.2.130.125:43995 ::ffff:xx.xx.119.188:5228 ESTABL
ISHED
tcp6 1 0 ::ffff:10.2.130.125:42353 ::ffff:xx.xx.23.110:80 CLOSE_WAI
T
tcp6 1 0 ::ffff:10.2.130.125:35722 ::ffff:xx.xx.205.170:443 CLOSE_WA
IT
tcp6 1 0 ::ffff:10.2.130.125:48101 ::ffff:xx.xx.205.110:443 CLOSE_WA
IT
I have also executed nmap -sS -Pn -p- 10.2.130.125. The output is:
Starting Nmap 7.60 ( https://nmap.org ) at 2018-01-18 16:10 W. Europe Standard T
ime
Nmap scan report for public-docking-cx-0635.ethz.ch (10.2.130.125)
Host is up (0.059s latency).
Not shown: 65534 filtered ports
PORT STATE SERVICE
22/tcp closed ssh
Nmap done: 1 IP address (1 host up) scanned in 159.90 seconds
Here is the stacktrace from the client. It is just a timeout exception. From the server I don't get any exception.
java.net.SocketTimeoutException: connect timed out
at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at inf.ethz.ch.streaming.server.main.Main$1.run(Main.java:164)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Maybe the port 13005 is being used, probably the last connection was not closed.
Connect your device via USB. Then go to the folder where you have adb and run the following:
adb shell
netstat -nap
This will show you all the active ports in the android device. You will be able to check if port 13005 is being used.
If you have lot of connections, then is better to apply grep to step 2.
netstat -na |grep 13005
Then try to use another port, for example 5001. If the port is not restricted and is free, you should be able to connect.
Are you sure that the port is available from outside?
You have to open the port in your router configuration.
I need to attach a jdb debug session to a java application that is being executed in a remote host, but I am unable to do it. I am working on linux, with openjdk 1.8.0_65, 64-Bit Server VM.
What I have tried
In order to enable the port listening, I have run the java application adding the following arguments to the command line:
-Xdebug -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:8000,server=y,suspend=n
The following message is displayed in the console:
Listening for transport dt_socket at address: 8000
And the application starts running normally.
Then, from the remote host, I execute the following command:
> jdb -connect com.sun.jdi.SocketAttach:hostname=<remote_host>,port=8000
It fails, the output is:
java.net.ConnectException: Conexión rehusada
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
[...]
Fatal error:
Unable to attach to target VM.
What I have checked
In order to check that the port is actually open and I can connect to it from the remote host, I have performed the following operations:
Lets call the host that is executing the java app. hostA, and the one from which I wan to attach the jdb hostB, then:
Check that there is actually a socket listening on port 8000 in hostA
> netstat -tualpn | grep :8000
tcp 0 0 127.0.0.1:8000 0.0.0.0:* LISTEN 1399/<app_name>
In hostA, check that I can connect to the port 8000 (in other words, try to connect from the local host)
> nc -vz localhost 8000
nc: connect to localhost port 8000 (tcp) failed: Connection refused
Connection to localhost 8000 port [tcp/irdmi] succeeded!
With telnet, it seems that it can connect but the connection is closed as soon as it is stablished, maybe because the JVM is expecting some sort of request?
> telnet localhost 8000
Trying ::1...
telnet: connect to address ::1: Connection refused
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
Connection closed by foreign host.
The java app. displays the following message when telnet connection is closed:
Debugger failed to attach: timeout during handshak
From hostB, check that I can connect to hostA, port 8000
> nc -vz hostA 8000
nc: connect to hostA port 8000 (tcp) failed: Connection refused
With telnet:
> telnet hostA 8000
Trying 172.17.10.127...
telnet: connect to address 172.17.10.127: Connection refused
So, I can't connect from hostA to hostB through the port 8000, although the JVM is listenning in the port 8000, in hostA.
Since the above fails, I have checked if the firewall is causing the connection refused. I have done it by using the nc command:
In hostA:
# First kill the java app (otherwise the port is busy), then:
> nc -l 8000
In hostB:
> nc -vz <hostA> 8000
Connection to hostA 8000 port [tcp/irdmi] succeeded!
As far as I understand, the above means that there is no firewall (or equivalent) blocking the port.
EDIT
Of course, I have tried to do jdb -attach but it fails even doing it from hostA.
I don't have enough points to comment. So I'm including this as an answer. It really isn't. BUT:
-Xdebug -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:8000,serv=y,suspend=n
Isn't it supposed to be:
-Xdebug -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:8000,server=y,suspend=n
??
[EDIT] You are probably already accounting for this - but also, if you are listening on 127.0.0.1, then it stands to reason that you won't connect from a remote computer. No doubt you are using an actual address, and just didn't include it here...
I have found the connection problem. In the command I use to launch the java application, I have changed the address parameter as following:
Before:
-Xdebug -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:8000,server=y,suspend=n
After (see address):
-Xdebug -agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n
while trying to create a new connection to rabbitmq running on a different server, I got the following error:
java.io.IOException
at com.rabbitmq.client.impl.AMQChannel.wrap(AMQChannel.java:106)
at com.rabbitmq.client.impl.AMQChannel.wrap(AMQChannel.java:102)
at com.rabbitmq.client.impl.AMQChannel.exnWrappingRpc(AMQChannel.java:124)
at com.rabbitmq.client.impl.AMQConnection.start(AMQConnection.java:406)
at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:516)
at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:533)
Caused by: com.rabbitmq.client.ShutdownSignalException: connection error; reason: java.net.SocketException: Connection reset
at com.rabbitmq.utility.ValueOrException.getValue(ValueOrException.java:67)
at com.rabbitmq.utility.BlockingValueOrException.uninterruptibleGetValue(BlockingValueOrException.java:33)
at com.rabbitmq.client.impl.AMQChannel$BlockingRpcContinuation.getReply(AMQChannel.java:343)
at com.rabbitmq.client.impl.AMQChannel.privateRpc(AMQChannel.java:216)
at com.rabbitmq.client.impl.AMQChannel.exnWrappingRpc(AMQChannel.java:118)
Caused by: java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(Unknown Source)
at java.net.SocketInputStream.read(Unknown Source)
at java.io.BufferedInputStream.fill(Unknown Source)
at java.io.BufferedInputStream.read(Unknown Source)
at java.io.DataInputStream.readUnsignedByte(Unknown Source)
at com.rabbitmq.client.impl.Frame.readFrom(Frame.java:95)
at com.rabbitmq.client.impl.SocketFrameHandler.readFrame(SocketFrameHandler.java:131)
at com.rabbitmq.client.impl.AMQConnection$MainLoop.run(AMQConnection.java:533)
Steps taken :
rabbitmq is running on the server.
server is specified
default port is specified
lsof -i tcp:5672
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
beam.smp 3084 rabbitmq 15u IPv6 18611 0t0 TCP *:amqp (LISTEN)
rabbitmqctl list_connections
Listing connections ...
guest client_server 55765 running
...done.
netstat -tapnl | grep 5672
tcp 0 0 0.0.0.0:15672 0.0.0.0:* LISTEN 3084/beam.smp
tcp 0 0 0.0.0.0:55672 0.0.0.0:* LISTEN 3084/beam.smp
tcp 0 0 :::5672 :::* LISTEN 3084/beam.smp
One of the possible reasons is that user you are connecting with to RabbitMQ has no rights to access to virtual hosts.
You can check this using Management Plugin (Admin tab).
Do not specify the default port as you have mentioned in your steps.
If you have not created virtual host on the actual server, where you are trying to connect, Do create a virtual host and give it admin permision.
Set the virtual host on the factory before creating the new connection, like factory.setVirtualHost("VIRTUAL_HOST_NAME_ON_SERVER");
Make sure username on the server on which you are trying to connect is Admin and have access to the Virtual Host you just created.
Specify your username and password along with virtual host, while getting the connection.
Start your application in Debug Mode, and check if it now passes, factory.newConection();
This should make your things work.
Got the same exception, and it worked for me.
If it still does not work paste your code snippet.
Check the host and port value
In application.properties
spring.rabbitmq.host=localhost
spring.rabbitmq.port=5672
spring.rabbitmq.username=guest
spring.rabbitmq.password=guest
See RabbitMQ site is running on port 15672 whereas in code using amqp protocol.
You can check if the SSL/TLS support is enabled. Then use the instruction useSslProtocol :
ConnectionFactory factory = new ConnectionFactory();
factory.useSslProtocol();
I got Unable to connect to AMQP server error when create a new connection. It was confirmed that it was a problem with the firewall. I solved it by command systemctl stop firewalld.
I successfully installed and run Hadoop on a single machine whose ip is 192.168.1.109 (In fact it is actually an Ubuntu instance running on virtual box ) .
When typing jps it shows
2473 DataNode
2765 TaskTracker
3373 Jps
2361 NameNode
2588 SecondaryNameNode
2655 JobTracker
This should mean that the hadoop is up and running.
Running commands like ./hadoop fs -ls is fine and produces the expected result.
But If I try to connect it from my windows box whose ip is 192.168.1.80 by writing
Java code's HDFS API to connect it as follows:
Configuration conf = new Configuration();
FileSystem hdfs = null;
Path filenamePath = new Path(FILE_NAME);
hdfs = FileSystem.get(conf); <-- the problem occurred at this line
when I run the code, the error displayed as follows:
11/12/07 20:37:24 INFO ipc.Client: Retrying connect to server: /192.168.1.109:9000. Already tried 0 time(s).
11/12/07 20:37:26 INFO ipc.Client: Retrying connect to server: /192.168.1.109:9000. Already tried 1 time(s).
11/12/07 20:37:28 INFO ipc.Client: Retrying connect to server: /192.168.1.109:9000. Already tried 2 time(s).
11/12/07 20:37:30 INFO ipc.Client: Retrying connect to server: /192.168.1.109:9000. Already tried 3 time(s).
11/12/07 20:37:32 INFO ipc.Client: Retrying connect to server: /192.168.1.109:9000. Already tried 4 time(s).
11/12/07 20:37:33 INFO ipc.Client: Retrying connect to server: /192.168.1.109:9000. Already tried 5 time(s).
11/12/07 20:37:35 INFO ipc.Client: Retrying connect to server: /192.168.1.109:9000. Already tried 6 time(s).
11/12/07 20:37:37 INFO ipc.Client: Retrying connect to server: /192.168.1.109:9000. Already tried 7 time(s).
11/12/07 20:37:39 INFO ipc.Client: Retrying connect to server: /192.168.1.109:9000. Already tried 8 time(s).
11/12/07 20:37:41 INFO ipc.Client: Retrying connect to server: /192.168.1.109:9000. Already tried 9 time(s).
java.net.ConnectException: Call to /192.168.1.109:9000 failed on connection exception: java.net.ConnectException: Connection refused: no further information
To make sure if the socket is already opened and waits for the incoming connections on the hadoop serer, I netstat on the ubuntu box
the result shows as follows:
tcp 0 0 localhost:51201 : LISTEN 2765/java
tcp 0 0 *:50020 : LISTEN 2473/java
tcp 0 0 localhost:9000 : LISTEN 2361/java
tcp 0 0 localhost:9001 : LISTEN 2655/java
tcp 0 0 *:mysql : LISTEN -
tcp 0 0 *:50090 : LISTEN 2588/java
tcp 0 0 *:11211 : LISTEN -
tcp 0 0 *:40843 : LISTEN 2473/java
tcp 0 0 *:58699 : LISTEN -
tcp 0 0 *:50060 : LISTEN 2765/java
tcp 0 0 *:50030 : LISTEN 2655/java
tcp 0 0 *:53966 : LISTEN 2655/java
tcp 0 0 *:www : LISTEN -
tcp 0 0 *:epmd : LISTEN -
tcp 0 0 *:55826 : LISTEN 2588/java
tcp 0 0 *:ftp : LISTEN -
tcp 0 0 *:50070 : LISTEN 2361/java
tcp 0 0 *:52822 : LISTEN 2361/java
tcp 0 0 *:ssh : LISTEN -
tcp 0 0 *:55672 : LISTEN -
tcp 0 0 *:50010 : LISTEN 2473/java
tcp 0 0 *:50075 : LISTEN 2473/java
I noticed that if the local address column is something like localhost:9000 (starts with localhost: not *:)
It will not be able to be connected from remote host or even in it own box in some case.
I tried telnet localhost 9000 it works, I means it can connect to the port but If I use telnet 192.168.1.109 9000
The errors displays like
$ telnet 192.168.1.109 9000
Trying 192.168.1.109...
telnet: Unable to connect to remote host: Connection refused
I have spent almost a week figuring out the issue I am really exhausted now and I hope someone can help me.
Note: I am not sure if namenode by default refuses remote connection. Do I need to change some settings in order for it to allow
remote connections?
Change the value of fs.default.name to hdfs://106.77.211.187:9000 from hdfs://localhost:9000in core-site.xml for both the client and the NameNode. Replace the IP address with the IP address of the node on which the NameNode is running or with the hostname.
Was able to telnet 106.77.211.187 9000 and here is the output of netstat -a | grep 9000
tcp6 0 0 106.77.211.187:9000 [::]:* LISTEN
tcp6 0 0 106.77.211.187:50753 106.77.211.187%819:9000 ESTABLISHED
tcp6 0 0 106.77.211.187:9000 106.77.211.187%81:50753 ESTABLISHED
As to why, the source code look like the following for fs.default.name set to localhost
ServerSocket socket = new ServerSocket(9000);
socket.bind(localhost);
Because bind address is assigned to localhost, the namenode process only can accept connection from localhost. If bind address is assigned to the name of machine name or ip address, then namenode process can accept any connection from remote machine.
I replaced all localhost with its ip address in all configuration file, now it is working fine.
Check /etc/hosts file and make sure you have the IP associated with the fully qualified name (FQN) of your node. Example:
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.100.11 node1.mydomain.com node1
192.168.100.12 node2.mydomain.com node2
In my case, I had line 127.0.0.1 node1.mydomain.com which was definetly wrong.
I faced the same issue but was able to get it fixed by doing the following. I had the hadoop master and slaves as CentOS7 VirtualBox VMs and I couldn't access web GUIs from the windows host by using the IP address and port of the Master node. Make sure you follow the steps given below to get it fixed;
As mentioned in the others posts, make sure the /etc/hosts file is correctly populated
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
172.10.2.20 hdp-master1.hadoop.cluster hdp-master1
172.10.2.21 hdp-slave1.hadoop.cluster hdp-slave1
172.10.2.22 hdp-slave2.hadoop.cluster hdp-slave2
And in all your hadoop xml files use the fully qualified hostname or ip instead of localhost, as others have mentioned
Add the following entry to hdfs-site.xml to make the web gui port to run from ip instead of 0.0.0.0:9870
<property>
<name>dfs.namenode.http-address</name>
<value>hdp-master1.hadoop.cluster:9870</value>
</property>
Add the following entry to yarn-site.xml to make the resource manager web gui port to run from ip instead of 0.0.0.0:8088
<property>
<name>yarn.resourcemanager.webapp.address</name>
<value>hdp-master1.hadoop.cluster:8088</value>
</property>
<property>
<name>yarn.resourcemanager.webapp.https.address</name>
<value>hdp-master1.hadoop.cluster:8090</value>
</property>
Stop and Start all services using start-all.sh. Just to be safe I ran hdfs namenode -format first before restarting services
Use netstat -tulnp on master node and make sure web ports run based on the ip
netstat -tulnp
tcp 0 0 172.16.3.20:8088 0.0.0.0:* LISTEN 14651/java
tcp 0 0 172.16.3.20:9870 0.0.0.0:* LISTEN 14167/java
Even after all that, I still couldn't access from the windows host and the culprit was the firewall on the hadoop nodes. So stop stop the firewall on all master and slave node as below
Check status
------------
systemctl status firewalld
Stop Firewall
-------------
systemctl stop firewalld
Disable from Startup
--------------------
systemclt disable firewalld
Now you should be able to access from the windows host through a web browser. I had entries added to windows hosts file so the even the following worked
http://hdp-master1.hadoop.cluster:9870
http://hdp-master1.hadoop.cluster:8088
Hope this helps