title: Why can't I connect to http server on localhost through a browser?
body: <p>I wrote a very simple Java http server for exercising purposes. I test it with cURL and everything seems to work fine but when I try to send a request from a browser </p>
  
  <pre><code>http://localhost:6666/
  </code></pre>
  
  <p>the server does not respond. I even put a marking System.out.println() at the point when the server socket accepts a connection which doesn't seem to fire when i try to hit the server through a browser. Please help me out with this.
  Thanks :)</p>
  
  <p>EDIT:
  Part of the code:</p>
  
  <pre><code>public class Server {
  
      private ServerSocket serverSocket;
      private Socket socket;
      public Server() {
          try {
              serverSocket = new ServerSocket(6666);
              while (true) {
                  socket = serverSocket.accept();
                  System.out.println("Whoop! Connection!");
                  Request request = new Request(socket);
                  request.run();
              }
          } catch (IOException e) {
              e.printStackTrace();
            }
      }
  }
  </code></pre>
  
  <p>Where Request is a class which extends Thread in order to handle multiple requests</p>