T
T
Turkmen Time2021-08-23 21:37:41
Python
Turkmen Time, 2021-08-23 21:37:41

How to fix error in socket.getaddrinfo()?

I get an error when I want to get ip from a domain

import socket

ip_new = socket.getaddrinfo(address, port)[0][4][0]


Mistake:
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -2] Name or service not known


The domain has an ip and the error occurs after 3-4 hours of the script, if you restart everything is fine again
socket.gethostbyname() also gives the same error

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question