Python on Amazon Linux 2 fails to resolve remote RDS host

0

I installed Amazon Linux 2 as WSL on my Windows machine. I have a simple Python code to connect AWS RDS, which runs fine on Windows, but fails on Amazon Linux 2, with the following error.

Traceback (most recent call last):
  File "src/oracledb/impl/thin/connection.pyx", line 102, in oracledb.thin_impl.ThinConnImpl._connect_with_address
  File "src/oracledb/impl/thin/protocol.pyx", line 150, in oracledb.thin_impl.Protocol._connect_phase_one
  File "src/oracledb/impl/thin/protocol.pyx", line 262, in oracledb.thin_impl.Protocol._connect_tcp
  File "/usr/local/lib/python3.10/socket.py", line 824, in create_connection
    for res in getaddrinfo(host, port, 0, SOCK_STREAM):
  File "/usr/local/lib/python3.10/socket.py", line 955, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -2] Name or service not known

I followed instructions on this page to install Python on Amazon Linux 2.

Please advise what might be the cause and what should do to resolve it. Thank you in advance.

Gary Y
gefragt vor einem Jahr247 Aufrufe
2 Antworten
0
Akzeptierte Antwort

This post helped me to resolve the issue.

Gary Y
beantwortet vor einem Jahr
profile picture
EXPERTE
überprüft vor 2 Monaten
  • It’s exactly what my answer was.

0

I think WSL uses a different DNS server than your operating system. It uses a docker network dns server.

Try and update your /etc/resolv.conf to the same name server as your windows machine and see if this resolves the issue

This should be a permanent fix https://dev.to/abhiweb/set-persist-google-dns-server-in-wsl2-notes-4364

profile picture
EXPERTE
beantwortet vor einem Jahr
  • Thank you Gary Mclean! Since I have AWS VPN connection, I updated the nameserver to the DNS server associated to the VPN, but it didn't work. The one associated with my wi-fi connection didn't work either. Any more suggestions?

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen