Sign up ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

To access, I entered the following commands:

telnet 80 > log
get /rfc.html HTTP/1.1

While I was in the midst of typing the 3rd command, the following message displayed :

Connection closed by foreign host.

The log entry was :

> Trying
Connected to
Escape character is '^]'.
HTTP/1.1 400 Bad Request
Date: Thu, 27 Dec 2012 09:32:01 GMT
Server: Apache/2.2.10 (Linux/SUSE) mod_ssl/2.2.10 OpenSSL/0.9.8h PHP/5.2.13 with     Suhosin-Patch mod_python/3.3.1 Python/2.6 mod_wsgi/3.3 mod_perl/2.0.4 Perl/v5.10.0
Content-Length: 226
Connection: close
Content-Type: text/html; charset=iso-8859-1

<title>400 Bad Request</title>
<h1>Bad Request</h1>
<p>Your browser sent a request that this server could not understand.<br />

So what's the problem?

share|improve this question
I think you should use wget –  Eric Carvalho Dec 27 '12 at 12:09

1 Answer 1

Assuming you are able to retrieve the file with wget as Eric Carvalho suggested (wget, the problem is likely just that the web server hung up on you because you didn't send your request fast enough.

Each time a page is retrieved, a separate TCP connection is made to the web server's HTTP port. Once connected, if you don't send a command soon enough, the server will assume that the connection is abandoned (which happens quite often, even though most web browsers minimize it by properly terminating their TCP connections when they're done).

If your goal is just to download the page and look at it, you should use wget, curl, or fetch instead of telnet. You can view the file on the command line with cat or less.

If your goal is to play around with using telnet to access web content--for example, to enhance your understanding of HTTP--then you might consider writing a program or script (it could even be a shell script) that acts as a simple front-end for telnet by taking the server's name and HTTP commands, and then connects to the server, sending the command(s) quickly thereafter.

share|improve this answer
Could it be a server-specific problem? Because I tried the following and it worked: telnet 80 >log get /pages/world/index.html HTTP/1.1 host: Connection closed by foreign host. And I took my sweet time typing the commands. –  Copperfield Dec 29 '12 at 13:40
The log contained the full,correct html page.Could the issue be related to the connection parameters set by the server? –  Copperfield Dec 29 '12 at 13:48
@Copperfield Yes, it could be a problem with the server. If everything had been working properly, I think you should have seen a 408 timeout error. –  Eliah Kagan Dec 29 '12 at 15:43

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.