0

I'm learning about ports and was mucking around. I found out that when I visit http://google.com:8000 (a port I chose at random), my browser times out after hanging for a while.

But when I visit http://google.com:443, I get an error immediately. (The text of the error appears to be browser-specific -- Chrome says "Empty response", while Safari claims the server "unexpectedly dropped the connection".)

I know that 443 is the default port for the HTTPS protocol, so I guessed that might have something to do with it, but I'm not familiar enough with these concepts to tease it out. In particular, could someone walk me through what is happening when I specify a bad port number and my browser hangs (for about 1 minute) before timing out?

1 Answer 1

3

When you are going to somewhere using a browser and specifying a port, you are attempting to make a (TCP) connection to that port.

When you run a service (like a web server for example), it runs on a specific port. If you try and connect to a machine and there is no program running associated with that port (the correct term is bound to the port), or it is firewalled, then it will time out.

When you went to Google on port 8000, there was no service running on it, so it timed out. (It actually tries to connect a few times incase there is an error the first few times to make things more robust)

When you went to Google on port 443, you successfully made a connection, because 443 is typically used for HTTPS - ie secure connections. Because you did not initiate a secure connection as per the HTTPS protocol, you had Chrome and Firefox behave that way.

Advanced Answer

When making a connection on TCP, there is a "3 way handshake" - The client sends a "SYN" packet to the server. The server receives this, and them assuming there is a program running, it sends back a "SYN-ACK" acknowledgement, then the client sends an "ACK" packet to the server - at which time the systems have established a connection.

In the case of connecting to port 8000, the client does not get a response to the SYN packet, so it tries a few times, and then gives up and times out.

In the case of connecting to port 443, a connection is established at the TCP level. At this time the server expects to negotiate an SSL connection for security (because its configured to do so on port 443). You don't know how to speak SSL, so it failed.

Bonus Points

If you have TELNET installed - most systems do , you can pretend to be a browser (or a mail client or whatever if you know the protocol), by doing the following.

1.  type "telnet www.google.com 80"
(wait for a few seconds)
2.  Type GET / HTTP/1.1<enter>
host www.google.com<enter><enter>

Step 1 tells Telnet to create a TCP connection to Googles server on port 80, and step 2 Says what to get (GET / means get the root file), and the line "host" says what server you are wanting to connect to - you need this because a lot of websites share a single server - the second line tells the server which site. You press enter twice to say you are finished sending your header, and then get back an HTTP response. (If you were a web browser, you would send a lot more information, including the browser details, cookies etc - but for explanation purposes we did not do this.)

2
  • Thanks for the thorough response. So if I specify a port which no service is running on, what is happening on the hardware level on the server side? Do the packets get "delivered", but not picked up? Does that concept even apply -- I'm thinking of a port as a repository of packets, but maybe I'm totally off. Is it more of just a tag that comes with each packet?
    – Eli Rose
    Feb 15, 2016 at 15:19
  • Packets get delivered (to the server) but not picked up( ie ignored by the service). Note that this happens in software, not hardware. Your computer has a ” tcp/ip” network stack.basically a network driver - which talks to your network card and provides the underlying communication protocols.
    – davidgo
    Feb 15, 2016 at 18:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .