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

Connection closed by foreign host...

Hi All,

I'm following along with the tutorial, but I'm not getting any response from the httpbin.org server. I'm connecting just fine, but both my local terminal and the console in workspaces are returning "Connection closed by foreign host.". I can connect to the site through a browser. Any ideas most welcome!

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

After a failed attempt I reset the console(work space) and completed the first action as mentioned, I then pasted the text below into the console and pressed return twice. Yah me! It worked. & Thanks Jason Anders.

GET / HTTP/1.1 Host: httpbin.org

3 Answers

Tiger Wang
Tiger Wang
26,548 Points

Hey Simon, I encountered the same problem, and I found after typing

GET / HTTP/1.1
Host: httpbin.org

You should press enter twice, I guess that telnet is waiting for you to give the rest of the request. BTW:Christ has been talking so fast :D .

Nailed it!

Ramy Elsaraf
Ramy Elsaraf
7,633 Points

How do you type the second line without pressing enter, how do you get down ????

Jason Anders
Jason Anders
Treehouse Moderator 145,858 Points

Hey Simon,

The "connection closed by foreign host" will come up ~60 seconds after you open the connection if there is no action. This is normal and done by httpbin.org. I found it best to watch what Chris does completely then pause / rewind and follow along (with your new connection). If you don't, sometimes he explains what he is doing for longer than 60 seconds, and then you will lose the connection just as he types the commands.

Hope this helps. :dizzy:

Thanks Jason. Sadly, I've been doing exactly that! Thanks for the advice. :)

Simon, did you go to a new line by pressing enter after typing HTTP/1.1?