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
demandé il y a un an247 vues
2 réponses
0
Réponse acceptée

This post helped me to resolve the issue.

Gary Y
répondu il y a un an
profile picture
EXPERT
vérifié il y a 2 mois
  • 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
EXPERT
répondu il y a un an
  • 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?

Vous n'êtes pas connecté. Se connecter pour publier une réponse.

Une bonne réponse répond clairement à la question, contient des commentaires constructifs et encourage le développement professionnel de la personne qui pose la question.

Instructions pour répondre aux questions