M
M
marz1k2022-01-10 16:32:06
Python
marz1k, 2022-01-10 16:32:06

The requested address is not valid in its context?

AWS provides static-ip for connections, but when I try to run a python server on it, I get sent far and long

import socket
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.bind(("тут айпи", 8888))
result = sock.recv(1024)
print("message ", result.decode("utf-8"))
sock.close()


The error looks like this: OSError: [WinError 10049] The requested address is not valid in its context

Firewall disabled, exceptions added

Answer the question

In order to leave comments, you need to log in

3 answer(s)
V
vreitech, 2022-01-10
@fzfx

this error occurs when the IP specified in sock.bind does not belong to any of the interfaces of the host where the code is running. in sock.bind, you must specify an IP address belonging to one of the host interfaces, or a binding to all interfaces at once ( 0.0.0.0).

M
mureevms, 2022-01-10
@mureevms

AWS does not assign a white IP to an instance's system interface. This is an AWS feature. No need to climb into the system to configure the network, not at all. The IP is attached from the management console to the instance, but does not belong to the OS, so the guys above correctly write that you need to bind the service to 0.0.0.0

A
Another One DevOps, 2022-01-10
@bsalbiev

"IP here" depending on if it's the server itself, use 127.0.0.1 or 0.0.0.0 there

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question