Windows: Using PuTTY as a Telnet client

88

There have been a lot of questions regarding using telnet to issue HTTP requests.

For example, here is one thread with many answers regarding the use of Microsoft/Windows telnet: http://forums.udacity.com/cs253-april2012/questions/65/microsoft-telnet

A lot of people have been having problems with it, or have been unable to install the telnet client on Windows 7.

An alternative is to use PuTTY, a free telnet client: http://www.chiark.greenend.org.uk/~sgtatham/putty/

Here are some instructions to use PuTTY to connect to web servers and send HTTP requests.

Note: These instructions were developed on Windows. Putty is also available for Unix systems, but if you're using Linux, you likely already have a built-in telnet program, or you know what you're doing.

Procedure

  1. Download and run putty.exe.
  2. Under Connection > Telnet select Passive for Telnet negotiation mode.
  3. Under Window type a large number (e.g. 1000) in Lines of scrollback. This will allow you to see the entire HTTP response if it's too long.
    Alternatively (perhaps preferably), you can set logging options under Session > Logging. Set Session logging to All session output and choose a log file destination (default will be in the same directory that putty.exe is located in). You can then review this log file in Notepad or another text editor to see the full (and formatted) response.
  4. Return to the Session page, and select Telnet for Connection type.
  5. Type in the desired hostname (i.e. www.udacity.com) in the Host Name field.
  6. Type 80 in the Port field.
  7. Select Never under Close window on exit.
    Important: At this point, you can save these session settings so you won't have to set them up every time! Just type a name in the box under Saved sessions, maybe "Telnet for http" or something, and click Save. In the future, you can just select this session from the list and click Load. Now you just have to set a new hostname and you're good to go!
  8. Click Open.
  9. You should see a blank terminal window. Notice that the window title shows ghs.l.google.com. This is good - it means you successfully connected to the web server at that address and it's waiting for your request.
    enter image description here
  10. Type in your HTTP request, with a single line break between each line in the request, like this:
    enter image description here
  11. Press Enter twice, once to move to the next line in your request, and then once more to tell the server your request is complete.
  12. You'll see some text flash by, and then a dialog box indicating the connection was closed, like this:
    enter image description here
  13. You can close the notification dialog, and then scroll back up to the top of your Putty window, to see the HTTP request and response:
    enter image description here

Problems

The window closes right away!

Make sure you have Close window on exit set to Never. Otherwise, once the HTTP response is received, Putty feels that the session has closed properly and will close the window.

I get a 400 Bad Request error in my HTTP response

Make sure you have Telnet negotiation mode set to Passive under Connection > Telnet in your configuration.

I get a 404 Not Found error in my HTTP response

Did you forget to include Host: www.udacity.com in your HTTP request? For this example, you're connecting to a Google web server that handles many websites - you need to make sure to tell it where to send your request.

asked 20 Apr '12, 14:14

djboge's gravatar image

djboge
8.1k1418

accept rate: 0%

edited 20 Apr '12, 14:24

1

you are a golden god.

(24 Sep '12, 02:59)

entontoent

entontoent's gravatar image

hi i cant give the line break between HTTP/1.0 and Host:www............... when i press enter i get 400 error or when press shift+enter i get that huge markup still saying HTTP/1.0 not found, it does not let me type in Host: www.udacity.com, why

(19 Feb '13, 03:28)

anwar-1

anwar-1's gravatar image
1

OK, I vote for this post as the single most valuable post on Udacity (at least up until now!). I've even used Putty before and ashamed to say I could not get telnet to work right until reading this post. Even then, www.udacity.com doesn't work anymore (301 error is probably a lie used for security purposes), but www.example.com works beautifully. Just remember to type it again in the window (NOT www.udacity.com!) and hit return TWICE at the very end. Thanks so much!!

(08 Aug '13, 21:53)

Dell Anderson

Dell%20Anderson's gravatar image

23 Answers:

123next »

How to configure auto login ? as scripting for putty on window to login unix .

link

answered 26 Dec '13, 05:56

SDE's gravatar image

SDE
11

I was wondering:

Is it possible to keep the Telnet connection open until you exit PuTTY manually (e.g.: Alt+F4)?

I wish to use PuTTY to view multiple HTTP request/response pairs without having to start a new Telnet session each time. Am I hoping in vain here?

Any help would be much appreciated. :)

Cheers,
-Marty

link

answered 12 Sep '13, 23:22

Marty-21's gravatar image

Marty-21
261

thanks for the post...itz really very helpfull....was banging my head unil got here....

link

answered 18 Aug '13, 12:38

hardik-2's gravatar image

hardik-2
261

it worked for me after several trials, i discover that you must follow the syntax i.e GETspace/spaceHTTP/1.0 i.e GET / HTTP/1.0. Thank you all

link

answered 07 Aug '13, 05:58

ridwan-1's gravatar image

ridwan-1
261

FINALLY GOT THIS TO WORK! the putty settings made all the diff. however as of today 8/3/13 the url is NOT www.udacity.com. when i tried to interact with that location 301 code was returned, server permanently moved. when i tried connecting to www. example.com 80 and then used Host: www.example.com IT WORKED!!!! took me about 3 days to get this. i also sent output to a log file which is tremendously helpful.

GET / HTTP/1.0
Host: www.example.com

HTTP/1.0 200 OK
Accept-Ranges: bytes
Content-Type: text/html; charset=UTF-8
Date: Sat, 03 Aug 2013 17:06:37 GMT
Etag: "780602-4f6-4db31b2978ec0"
Last-Modified: Thu, 25 Apr 2013 16:13:23 GMT
Server: ECS (ftw/FBA9)
X-Cache: HIT
Content-Length: 1270
Connection: close

<html> <head> <title>Example Domain</title>
<meta charset="utf-8" />
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<style type="text/css">
body {
    background-color: #f0f0f2;
    margin: 0;
    padding: 0;
    font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;

}
div {
    width: 600px;
    margin: 5em auto;
    padding: 50px;
    background-color: #fff;
    border-radius: 1em;
}
a:link, a:visited {
    color: #38488f;
    text-decoration: none;
}
@media (max-width: 700px) {
    body {
        background-color: #fff;
    }
    div {
        width: auto;
        margin: 0 auto;
        border-radius: 0;
        padding: 1em;
    }
}
</style>

</head>

<body>


Example Domain


This domain is established to be used for illustrative examples in documents. You may use this
domain in examples without prior coordination or asking for permission.


More information...



</body>
</html>

link

answered 03 Aug '13, 13:15

Deborah-32's gravatar image

Deborah-32
411

Thank you. Now I can shower and shave and try to get my wife back.

link

answered 22 May '13, 09:33

Charles-138's gravatar image

Charles-138
261

14

anyone else get a 301 moved permanently?

link

answered 03 Feb '13, 15:58

Will-49's gravatar image

Will-49
22112

yes, and the output is of just a few lines !

(20 Feb '13, 06:03)

Nikunj Banka

Nikunj%20Banka's gravatar image
1

Has udacity.com moved to https://udacity.com? How do we connect to this site? This seems to be the source of the 301 error

(28 Feb '13, 00:59)

Ken Oh

Ken%20Oh's gravatar image

Thanks so much. It works!!!! This is an excellent post :-)

link

answered 20 Mar '13, 09:07

Yuki-2's gravatar image

Yuki-2
11

Hi when i type this line GET /HTTP/1.0 and press enter or sift+enter, it just immediately closes the connection and i get the 400 error, if instead press control+enter after typing the first line, i get the <!DOCTYPE HTML> and a long screen of text that at the end reads The requested URL HTTP/1.0 was not found, i have tried with HTTP/1.1 and i get the same it never lets me type in the second line Host: www.udacity.com whenever i try to put a line break, this is freaking me out.........why is it not letting me type this second line Host: www.udacity.com after the line break

link

answered 19 Feb '13, 02:41

anwar-1's gravatar image

anwar-1
664

you are my hero... using telnet in windows gave me a headache last week.

link

answered 05 Jan '13, 09:36

ganeshan%20dash's gravatar image

ganeshan dash
79124

Your answer
Question text:

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags

×13,571
×9,083
×402
×102
×60
×17
×6

Asked: 20 Apr '12, 14:14

Seen: 37,516 times

Last updated: 26 Dec '13, 05:56