java.net.SocketException: Permission denied

visibility 359 comment 0 access_time 10m languageEnglish

About the error

When trying to start Hadoop DFS services in WSL (Windows Subsystem for Linux), it failed with the following error:

2021-01-01 21:13:37,650 INFO org.apache.hadoop.http.HttpServer2: HttpServer.start() threw a non Bind IOException
java.net.BindException: Port in use: 0.0.0.0:9870
	at org.apache.hadoop.http.HttpServer2.constructBindException(HttpServer2.java:1292)
	at org.apache.hadoop.http.HttpServer2.bindForSinglePort(HttpServer2.java:1314)
	at org.apache.hadoop.http.HttpServer2.openListeners(HttpServer2.java:1373)
	at org.apache.hadoop.http.HttpServer2.start(HttpServer2.java:1223)
	at org.apache.hadoop.hdfs.server.namenode.NameNodeHttpServer.start(NameNodeHttpServer.java:170)
	at org.apache.hadoop.hdfs.server.namenode.NameNode.startHttpServer(NameNode.java:946)
	at org.apache.hadoop.hdfs.server.namenode.NameNode.initialize(NameNode.java:757)
	at org.apache.hadoop.hdfs.server.namenode.NameNode.<init>(NameNode.java:1014)
	at org.apache.hadoop.hdfs.server.namenode.NameNode.<init>(NameNode.java:987)
	at org.apache.hadoop.hdfs.server.namenode.NameNode.createNameNode(NameNode.java:1756)
	at org.apache.hadoop.hdfs.server.namenode.NameNode.main(NameNode.java:1821)
Caused by: java.net.SocketException: Permission denied
	at sun.nio.ch.Net.bind0(Native Method)
	at sun.nio.ch.Net.bind(Net.java:433)
	at sun.nio.ch.Net.bind(Net.java:425)
	at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:223)
	at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74)
	at org.eclipse.jetty.server.ServerConnector.openAcceptChannel(ServerConnector.java:342)
	at org.eclipse.jetty.server.ServerConnector.open(ServerConnector.java:307)
	at org.apache.hadoop.http.HttpServer2.bindListener(HttpServer2.java:1279)
	at org.apache.hadoop.http.HttpServer2.bindForSinglePort(HttpServer2.java:1310)
	... 9 more
2021-01-01 21:13:37,655 INFO org.apache.hadoop.metrics2.impl.MetricsSystemImpl: Stopping NameNode metrics system...
2021-01-01 21:13:37,656 INFO org.apache.hadoop.metrics2.impl.MetricsSystemImpl: NameNode metrics system stopped.
2021-01-01 21:13:37,656 INFO org.apache.hadoop.metrics2.impl.MetricsSystemImpl: NameNode metrics system shutdown complete.
2021-01-01 21:13:37,656 ERROR org.apache.hadoop.hdfs.server.namenode.NameNode: Failed to start namenode.
java.net.BindException: Port in use: 0.0.0.0:9870
	at org.apache.hadoop.http.HttpServer2.constructBindException(HttpServer2.java:1292)
	at org.apache.hadoop.http.HttpServer2.bindForSinglePort(HttpServer2.java:1314)
	at org.apache.hadoop.http.HttpServer2.openListeners(HttpServer2.java:1373)
	at org.apache.hadoop.http.HttpServer2.start(HttpServer2.java:1223)
	at org.apache.hadoop.hdfs.server.namenode.NameNodeHttpServer.start(NameNodeHttpServer.java:170)
	at org.apache.hadoop.hdfs.server.namenode.NameNode.startHttpServer(NameNode.java:946)
	at org.apache.hadoop.hdfs.server.namenode.NameNode.initialize(NameNode.java:757)
	at org.apache.hadoop.hdfs.server.namenode.NameNode.<init>(NameNode.java:1014)
	at org.apache.hadoop.hdfs.server.namenode.NameNode.<init>(NameNode.java:987)
	at org.apache.hadoop.hdfs.server.namenode.NameNode.createNameNode(NameNode.java:1756)
	at org.apache.hadoop.hdfs.server.namenode.NameNode.main(NameNode.java:1821)
Caused by: java.net.SocketException: Permission denied
	at sun.nio.ch.Net.bind0(Native Method)
	at sun.nio.ch.Net.bind(Net.java:433)
	at sun.nio.ch.Net.bind(Net.java:425)
	at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:223)
	at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74)
	at org.eclipse.jetty.server.ServerConnector.openAcceptChannel(ServerConnector.java:342)
	at org.eclipse.jetty.server.ServerConnector.open(ServerConnector.java:307)
	at org.apache.hadoop.http.HttpServer2.bindListener(HttpServer2.java:1279)
	at org.apache.hadoop.http.HttpServer2.bindForSinglePort(HttpServer2.java:1310)
	... 9 more
2021-01-01 21:13:37,659 INFO org.apache.hadoop.util.ExitUtil: Exiting with status 1: java.net.BindException: Port in use: 0.0.0.0:9870
2021-01-01 21:13:37,663 INFO org.apache.hadoop.hdfs.server.namenode.NameNode: SHUTDOWN_MSG: 

Debug

The following actions were conducted but nothing helps:

  • Use the following command in Command Prompt in Windows 10 (host) and the result is empty i.e. port is not used.
    netstat -ano |grep 9870
  • Modified HDFS configuration file to use different ports. Nothing
  • Confirmed HDFS namenode ports are not privileged ports. 
  • (For Windows incl. WSL) Follow this page to check if the port numbers are reserved by Hyper-V if it is enabled on your system: Resolution - Cannot Start MySQL on WSL.

Resolution

After digging through, finally the issue was fixed via the following approach:

  • Run WSL as Administrator

  • Then start HDFS services in the terminal.
info Last modified by Raymond 10m copyright This page is subject to Site terms.

Please log in or register to comment.

account_circle Log in person_add Register

Log in with external accounts

Tags