Answer the question
In order to leave comments, you need to log in
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()
Answer the question
In order to leave comments, you need to log in
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
).
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
"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 questionAsk a Question
731 491 924 answers to any question