Python - socket.error: Cannot assign requested address

user8513564

I have written a chat server but I cannot bind my socket to an IP address:

import sys
import os
import socket

HOST = "194.118.168.131"
SOCKET_LIST = []
RECV_BUFFER = 4096 
PORT = 9009

def chat_server():

    server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    server_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
    server_socket.bind((HOST, PORT))
    server_socket.listen(10)
...

I get the following error:

Traceback (most recent call last):
  File "server.py", line 83, in <module>
    sys.exit(chat_server())
  File "server.py", line 20, in chat_server
    server_socket.bind((HOST, PORT))
  File "/usr/lib/python2.7/socket.py", line 224, in meth
    return getattr(self._sock,name)(*args)
socket.error: [Errno 99] Cannot assign requested address

What's wrong with my code?


I didn't find an answer on:

'Connection aborted.', error(99, 'Cannot assign requested address') error in Python,
socket.error[Errno 99] Cannot assign requested address,
bind: cannot assign requested address
Cannot assign requested address - possible causes?

llllllllll

By checking errno.h, errno 99 is EADDRNOTAVAIL. The man page bind(2) says:

EADDRNOTAVAIL A nonexistent interface was requested or the requested address was not local.

It is often caused by a wrong IP address. You can use the command ifconfig to check whether your machine has this IP address.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

socket.error:[errno 99] cannot assign requested address and namespace in python

gin-gonic cannot assign requested address

RedisInsight on Docker and Redis on Docker: Could not connect: Error 99 connecting to localhost:6379. Cannot assign requested address

Netty SocketIO - Cannot assign requested address in AWS

Flask, cannot assign requested address

requests, cannot assign requested address, out of ports?

Docker for Windows: cannot assign requested address

Puma Error: Cannot assign requested address - bind(2) for "10.0.2.2" port 3000 (Errno::EADDRNOTAVAIL)

Cannot connect to redis://localhost:6379/0: Error 99 connecting to localhost:6379. Cannot assign requested address

PostgreSQL docker: "could not bind IPv6 socket: Cannot assign requested address"

OSError: [Errno 99] Cannot assign requested address

Server binding results in error "Cannot assign requested address"?

socket.error:[errno 99] cannot assign requested address : flask and python

ssh_init: Network error: Cannot assign requested address

Postgresql connection with gorm dial error cannot assign requested address

Cannot assign requested address (when using Docker)

Bind error (99): Cannot assign requested address

unable to bind socket: Cannot assign requested address issue on ubuntu

traceroute have error bind: Cannot assign requested address

Mesos bind error : Cannot assign requested address [99]

How to fix 'Cannot assign requested address?'

socket.error: [Errno 49] Can't assign requested address

Raspberry Pi TCP socket - [Errno 99] Cannot assign requested address

zmq.error.ZMQError: Cannot assign requested address

Nginx on Kubernetes (99: Cannot assign requested address)

Docker Cannot assign requested address

Errno 99 - Cannot assign requested address

Socket server failed to bind to kafka:29092: Cannot assign requested address

Cannot Assign requested Address in AWS - JAVA Server Socket