Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Development Tools HTTP Basics Introduction to HTTP HTTP Requests Using Telnet

Aarushi Rai
Aarushi Rai
1,474 Points

Unable to connect with Telnet - Connection closed by foreign host

The following error is occurring as I try and follow along with the video :

telnet httpbin.org 80 Trying 54.175.219.8... Connected to httpbin.org. Escape character is '^]'. GET/HTTP/1.1 Host : httpbin.org Connection closed by foreign host.

-As soon as I press enter after the "Host : hhtpbin.org" command, I get the error message before I can even press enter again.

3 Answers

I've tried accessing the resource at the mentioned address, and I found it successfully (as of Mars 2017).

Based upon your input, GET/HTTP/1.1 should cause a 400 Bad Request since the syntax is incorrect. There must be whitespace between the GET and / as well as after the / since the forward-slash refers to the root. Furthermore, the host confirmation on the request line that you've specified is incorrect, it must be httpbin.org.

So, it must be as following.

telnet httpbin.org 80

Once a connection has been established, and the prompt is open for input again. Enter.

GET / HTTP/1.1
Host: httpbin.org

You must type the request line quickly because of the inner workings of Telnet. Secondly, you must perform a carriage-return twice in order to submit the request.

@ Erdem and Aarushi its working we are missing somthing @ the second instruction

1st Instruction was...

>>> telnet httpbin.org 80

2nd Instruction...

GET / HTTP/1.1
Host: httpbin.org

Now after inputing this second command make sure u tap <ENTER> twice very fast

I am having the same problem with mac terminal. It doesnt give me enough time to write it(3-4 for secs)