Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask question.(5)

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

ITtutoria

ITtutoria Logo ITtutoria Logo

ITtutoria Navigation

  • Python
  • Java
  • Reactjs
  • JavaScript
  • R
  • PySpark
  • MYSQL
  • Pandas
  • QA
  • C++
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Python
  • Science
  • Java
  • JavaScript
  • Reactjs
  • Nodejs
  • Tools
  • QA
Home/ Questions/Amazing solutions for the oserror errno 99 cannot assign requested address error
Next
Answered
Abel Wang
  • 5
Abel Wang
Asked: May 18, 20222022-05-18T19:47:03+00:00 2022-05-18T19:47:03+00:00In: python

Amazing solutions for the oserror errno 99 cannot assign requested address error

  • 5

. Advertisement .

..3..

. Advertisement .

..4..

I get the error message:

*** Start Block *** 
errno99: cannot assign requested address

Has anyone ever faced this problem? How to troubleshoot the “oserror errno 99 cannot assign requested address.” The problem appears when I try to operate the following program:

#server code
 import select 
 import socket 
 import sys 
 backlog = 5 
 size = 1024 
 server = socket.socket(socket.AF_INET, socket.SOCK_STREAM) 
 server.bind(("10.0.0.1",9999)) 
 server.listen(backlog) 
 input = [server] 
 running = 1 
 while running: 
  inputready,outputready,exceptready = select.select(input,[],[]) 
  for s in inputready: 
  if s == server: 
  client, address = server.accept() 
  input.append(client)
  else: 
  l = s.recv(1024)
  sys.stdout.write(l)
 server.close()
#client code
 import socket
 import select
 import sys
 import time
 while(1) :
  s,addr=server1.accept() 
  data=int(s.recv(4))
  s = socket.socket()
  s.connect(("10.0.0.1",9999))
  while (1):
  f=open ("hello1.txt", "rb")
  l = f.read(1024)
  s.send(l)
  l = f.read(1024)
  time.sleep(5)
 s.close()
cannot assign requested address
  • 2 2 Answers
  • 759 Views
  • 0 Followers
  • 0
Answer
Share
  • Facebook
  • Report

2 Answers

  • Voted
  • Oldest
  • Recent
  • Random
  1. Best Answer
    hdtutoria Expert
    2022-06-20T01:54:50+00:00Added an answer on June 20, 2022 at 1:54 am

    The cause: It’s complaining about a problem with the IP address rather than the port.

    When you bind localhost or 127.0.0.1, you can only connect to your service from local.

    You can’t bind 10.0.0.1 because it’s not yours; you can only bind IP addresses that belong to your computer.

    Solution: Making everything become basic and perhaps you would like to test things below:

    import socket
    server = socket.socket()
    server.bind(("10.0.0.1", 6677))
    server.listen(4)
    client_socket, client_address = server.accept()
    print(client_address, "has connected")
    while True:
        recvieved_data = client_socket.recv(1024)
        print(recvieved_data)
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report
  2. Julia Guillard
    2022-05-25T20:57:41+00:00Added an answer on May 25, 2022 at 8:57 pm

    This error will also be displayed if the Docker container is not actively serving the port.

    If you request a local URL that isn’t served by a host that has no listening/bound port, you will get a No connection could be made because the target machine actively refused it error. If you create a container that binds the port but no server is running within it, requests to that port from localhost will be returned as:

    • [Errno 99] Cannot assign requested address (if called within the container),
    • [Errno 0] Error (if called outside the container).

    This error and the behavior described above can be reproduced as follows:

    Create a dummy container ( Note: This will pull the Python image from if it is not available locally ).

    docker run --name serv1 -p 5000:5000 -dit python

    For [Errno 0] Error, you will need to enter a Python Console on host. [Errno 99] Cannot assign requested address will allow you to access a Python Console on the Container by calling:

    docker exec -it -u 0 serv1 python

    In either case, call:

    import urllib.request
    urllib.request.urlopen('https://localhost:5000')

    I decided to treat these errors as No connection could be made because the target machine actively refused it equivalents rather than try to fix them – though please let me know if this is a bad idea.

    This one took me over a whole day to figure out. All resources and answers that I could find on [Errno 99] Cannot assign requested address pointed in the right direction: binding to an occupied port; connecting to an invalid address; sysctl conflicts; docker network issues; TIME_WAIT being wrong, and many other things. This answer is not a direct answer to your question, but it could be a common cause of the error that you are describing in the question.

    • 10
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

Sidebar

Ask A Question
  • How to Split String by space in C++
  • How To Convert A Pandas DataFrame Column To A List
  • How to Replace Multiple Characters in A String in Python?
  • How To Remove Special Characters From String Python

Explore

  • Home
  • Tutorial

Footer

ITtutoria

ITtutoria

This website is user friendly and will facilitate transferring knowledge. It would be useful for a self-initiated learning process.

@ ITTutoria Co Ltd.

Tutorial

  • Home
  • Python
  • Science
  • Java
  • JavaScript
  • Reactjs
  • Nodejs
  • Tools
  • QA

Legal Stuff

  • About Us
  • Terms of Use
  • Privacy Policy
  • Contact Us

DMCA.com Protection Status

Help

  • Knowledge Base
  • Support

Follow

© 2022 Ittutoria. All Rights Reserved.

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.