Trouble with PY4E Chapter 12, Understanding request/response cycle assignment. | Coursera Community
Coursera Header

Trouble with PY4E Chapter 12, Understanding request/response cycle assignment.

  • 9 November 2019
  • 3 replies

Badge +1

HI there. This is my first question on this forum. So here we go.

In the exercise I modified the url in the file as told to retrieve the document from the link provided. But after doing all and running in cmd, I get ‘socket.gaierror: [Errno 11001] getaddrinfo failed’ error. I also can’t get to work this with the other alternative methods i.e., browser developer console and telnet. Telnet throws a ‘Could not open connection to the host, on port 80: Connect failed’ error. I looked into google but not getting a clear answer. It would really help if someone solved this issue for me. I’m also putting in the code.


import socket

mysock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
mysock.connect(('', 80))
cmd = 'GET HTTP/1.0\r\n\r\n'.encode()

while True:
    data = mysock.recv(512)
    if len(data) < 1:


3 replies

Badge +1

Questions for specific course should be directed to the Discussion Forum of that particular course if you look at the specific course, and you would see the available Discussion Forum for each course including the Week that have all kinds of questions for that particular course. You may want to do read through the comments of the specific Discussion Forum before asking your questions if there are questions already answered. And every course has its own Discussion Forum since the people who put the course together know how to answer your questions related to that specific courses, which make sense. Hope this help.

Userlevel 1
Badge +2

Hi  Vishal,

I understood your question better to go through the course videos and notes in coursera they will be given  .And if you  have time to read the textbook,  take “Head First Python Text  book”or download from the internet  it is available and you can find the solution from  the given code  or as per said “YEN”   once see the discussion you can  solve for your question.


Just correct this line

mysock.connect(('', 80))


mysock.connect(('', 80))

first parameter is just the host to connect to the server