Search code examples
javaserverserversocket

loopback ip using socketserver on java


I have been tying to create a server on loop-back device using ServerSocket.

ServerSocket server = new ServerSocket(PORT, 0,  InetAddress.getByName(null));

The host to reach the server is provided as ip6-localhost/::1 however it results in error: ERR_INVALID_HTTP_RESPONSE

any pointer on how to access local server using 127.0.0.1?


Solution

  • Some of the answers and comments in this question address this problem. ie- passing in localhost or 127.0.0.1 instead

        ServerSocket server = new ServerSocket(9090, 0, InetAddress.getByName("localhost"))