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
질문됨 일 년 전247회 조회
2개 답변
0
수락된 답변

This post helped me to resolve the issue.

Gary Y
답변함 일 년 전
profile picture
전문가
검토됨 2달 전
  • 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
전문가
답변함 일 년 전
  • 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?

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠