java.net.SocketException: Permission denied

access_time 13 days ago visibility7 comment 0

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 10 days ago copyright This page is subject to Site terms.
Like this article?
Share on

Please log in or register to comment.

account_circle Log in person_add Register

Log in with external accounts

Follow Kontext

Get our latest updates on LinkedIn or Twitter.

Want to publish your article on Kontext?

Learn more

More from Kontext

visibility 3272
thumb_up 0
access_time 3 years ago

This page continues with the following documentation about configuring a Hadoop multi-nodes cluster via adding a new edge node to configure administration or client tools. Configure Hadoop 3.1.0 in a Multi Node Cluster In this page, I’m going to show you how to add a edge node into the ...

visibility 3156
thumb_up 0
access_time 2 years ago

This post shows you how to connect to HiveServer2 via Hive JDBC driver in Java. *The way to connect to HiveServer1 is very similar though the driver names are different: Version Driver Name HiveServer1 org.apache.hadoop.hive.jdbc.HiveDriver HiveServer2 ...

visibility 405
thumb_up 0
access_time 10 months ago

To read data from SQLite database in Python, you can use the built-in sqlite3 package . Another approach is to use SQLite JDBC driver via  JayDeBeApi  python package. Download the JAR file from one of the online repositories: Maven Repository BitBucket or any other equivalent ...