## Windows: Using PuTTY as a Telnet client

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

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.
10. Type in your HTTP request, with a single line break between each line in the request, like this:
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:
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:

## 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.

djboge
8.1k1418

accept rate: 0%

1

you are a golden god.

(24 Sep '12, 02:59)

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)

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)

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

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

Marty-21
261

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

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

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

<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;
font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;

}
div {
width: 600px;
margin: 5em auto;
background-color: #fff;
}
color: #38488f;
text-decoration: none;
}
@media (max-width: 700px) {
body {
background-color: #fff;
}
div {
width: auto;
margin: 0 auto;
}
}
</style>


<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.

</body>
</html>

Deborah-32
411

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

Charles-138
261

anyone else get a 301 moved permanently?

Will-49
22112

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

(20 Feb '13, 06:03)

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)

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

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

anwar-1
664

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

ganeshan dash
79125

Question text:

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• 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

×13,846
×9,100
×402
×105
×61
×19
×6