-2

When I run this bit of code:

import socket

domainName = 'test.domain.io'

old_ip = socket.gethostbyname(domainName)

print(old_ip)

I get this error in PyCharm: "File "C:/Users/UserName/PycharmProjects/AddyGet/ThingstoTry.py", line 5, in old_ip = socket.gethostbyname(domainName) socket.gaierror: [Errno 11001] getaddrinfo failed"

When I point the debugger at line 5, I see the following errors:

"ret.metadata= {NameError}name 'ret' is not defined"
"route53= {NameError}name 'route53' is not defined"
"zone= {NameError}name 'zone' is not defined"
"zone= {NameError}name 'zone' is not defined"
"route53.connection= {NameError}name 'route53' is not defined"

The domain is hosting on route53, but I'm not importing route53 because I didn't think I would need to just to retrieve an IP address. So, do I need to be importing route53 and working with route53 methods just to get this IP address? Any insights would be greatly appreciated.

Also worth mentioning, because it's a "socket.gaierror", I tried the solutions here: "getaddrinfo failed", what does that mean?

I am not behind a firewall (I disabled Window's firewall). There are no proxy environmental variables by default on my system, and putting myself behind a proxy also didn't help.

Flipscuba
  • 109
  • 4

1 Answers1

1

On my computer, running the code example, I get output 23.221.222.250.

It might not be a Python issue, but more an OS issue. What happens if you open a Windows cmd prompt and type:

ping test.domain.io

Here's my output (repetition and stats edited out):

Pinging test.domain.io [23.221.222.250] with 32 bytes of data:
Reply from 23.221.222.250: bytes=32 time=69ms TTL=47
...
VirtualScooter
  • 969
  • 1
  • 8
  • 18
  • It says "Ping request could not find test.domain.io". Please check name and try again. – Flipscuba Feb 17 '21 at 02:39
  • 2
    OK. Then this is clearly an OS (network setup) issue, not Python, since it seems that `test.domain.io` is a valid DNS name with a valid IP address. Oh, I'll mention this in the answer, too, but I ran your code example, and it worked fine for me. – VirtualScooter Feb 17 '21 at 02:46
  • Okay, so the next step would be connecting to a different network? – Flipscuba Feb 17 '21 at 02:47
  • 2
    Are you using this website on the same computer? It might be that you have a faulty DNS server in your network. What does `ping www.stackoverflow.com` do? – VirtualScooter Feb 17 '21 at 02:50
  • Gives me this: Pinging stackoverflow.com [151.101.193.69] with 32 bytes of data: Reply from 151.101.193.69: bytes=32 time=5ms TTL=58 and etc. – Flipscuba Feb 17 '21 at 02:54
  • 2
    Well, that's odd. It could be a custom entry in c:\windows\system32\drivers\etc\host. See https://superuser.com/q/1019467/1274805 for advice from the pros. – VirtualScooter Feb 17 '21 at 03:01
  • Thanks for all your help, I'll check that out! – Flipscuba Feb 17 '21 at 03:05