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
posta un anno fa247 visualizzazioni
2 Risposte
0
Risposta accettata

This post helped me to resolve the issue.

Gary Y
con risposta un anno fa
profile picture
ESPERTO
verificato 2 mesi fa
  • 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
ESPERTO
con risposta un anno fa
  • 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?

Accesso non effettuato. Accedi per postare una risposta.

Una buona risposta soddisfa chiaramente la domanda, fornisce un feedback costruttivo e incoraggia la crescita professionale del richiedente.

Linee guida per rispondere alle domande