Why can't I connect to http server on localhost through a browser?

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

http://localhost:6666/

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 :)

EDIT: Part of the 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();
          }
    }
}

Where Request is a class which extends Thread in order to handle multiple requests

The Academic - Why Can't We Be Friends? (Official Audio), 'Acting My Age' EP out now: https://theacademic.lnk.to/AMAEPID Listen to music from The Duration: 3:24 Posted: Nov 16, 2017 A list of compatible, supported file types and file extensions users can open in PowerPoint Mobile for iPad.

Looks like port 6666 is considered unsafe by many browsers for security reasons. Please try some other ports may be port 3000 or 5000(I am just throwing a number here) it should work.

Why can't you divide by zero? - TED-Ed, Check out our Patreon page: https://www.patreon.com/teded View full lesson: https://ed.ted.com Duration: 4:51 Posted: Apr 23, 2018 In PowerPoint for Microsoft 365 for Mac or PowerPoint 2019 for Mac, you can insert an online video from YouTube or Vimeo on a slide.. In PowerPoint for Microsoft 365 for Mac, you can also insert an online video from Microsoft Stream, a video service for enterprises—people in an organization can upload, view, and share videos with one another.

Browsers only understand http and some other protocols, such as ftp. Your serverSocket does not implement any protocol. If you want to see something, maybe you can try in console

# telnet localhost 6666 

EDIT

Here another question (and answer) for a correct implementation of an HTTP server: A Simple Http Server with Java/Socket?

Can't sign in to your Google Account, If you can't sign in to your Google Account in Gmail, Google Drive, Google Play, or elsewhere, select the issue that most closely applies to you. Follow the� Music video by Liz Phair performing Why Can't I?. #LizPhair #WhyCantI #Vevo

Login and New Account Troubleshooting, There are a few reasons you might be having trouble logging in or creating a new Snapchat You can try connecting to Wi-Fi if you have weak cellular service. Being overweight, getting too little exercise, and smoking all can work against the good blood flow that is key to erections. For some men, a little alcohol may help take the edge off.

Boost Unavailable on Facebook, To learn more about why your boost is unavailable or how you can boost a similar post, read the tip and match it to one of the reasons below. Boost unavailable� lyrics to why can't I by Liz Phair. Enjoy!! :) (Need and taking all requests!) 99 wc twins - reirarw and virginmobility dark desire studios

Why can't I post in a Facebook group?, We understand that this can be frustrating, so please keep in mind that you'll receive a notification at the top of the group indicating when you'll be able to post � More Americans can vote by mail in November than before the pandemic; find out which states have changed rules. Barring a landslide, we may not have a result in the presidential election on Nov. 3.

Comments
  • You're probably going to need to post some code. Other than that, maybe your browser proxy settings.
  • Doubt it will make a difference, but have you tried 127.0.0.1:6666?
  • Tried 127.0.0.1:6666 No effect
  • take a Wireshark trace of traffic from your browser to your server, and compare it to a trace of traffic from cURL to your server. Are there any differences?
  • you didn't understand the concept. A port itself can not "have security issues". You are referring to a specific service, IRC (Internet Relay Chat), which has issues. And it would have issues even if it was run on another port. In the question, he's creating a new service, completely unrelated to IRC.
  • Correct, but my point here is that port 6660 through 6669 (used for IRC) were targeted for malicious purpose in the past and that could be the reason if you try to open the http url with port 6666 in Chrome it doesn't work but same url works on Microsoft Edge or Firefox and this is strange. @tonjo Please try it for your self and let me know your findings. My suggestion is just use some another port.
  • Firefox on ubuntu clearly says "This address is restricted", so that is the reason. Any port could be targeted for malicious purposes, what kind of security would be simply not using certain ports? Nonsense. No need to be a Java expert (I am no), but even if you change port, that service using a generic ServerSocket is not an HTTP server. Try looking here, maybe it clarifies: stackoverflow.com/questions/10788125/…
  • Agreed, may be I should have said Looks like port 6666 has some restrictions from the certain browsers instead I mentioned security (my bad!). But @tonjo you got my point Firefox on ubuntu clearly says "This address is restricted" bingo! :) (and it's ok if you are not Java expert) I appreciate your efforts.
  • You are still completely missing the point. Your answer is wrong because you seem to ignore what an http server is. Have you tried the link? Try it, try also changing port. And study more.