Skip to content
mahler83 blog v2

Pharmacology, IoT, LLMs

mahler83 blog v2

Pharmacology, IoT, LLMs

python requests 오류: Temporary failure in name resolution

python requests 오류: Temporary failure in name resolution

mahler83, 2020-10-132023-07-19

간단하게 requests.get(url) 이런 식으로 웹페이지를 요청하는 코드에서 다음과 같은 오류가 발생했다. 로컬에서는 동작하는데 서버에 올리니 동작을 안 하는 상황.

Traceback (most recent call last):

  File "", line 1, in 

  File "/usr/local/lib/python3.6/site-packages/requests/api.py", line 72, in get

    return request('get', url, params=params, **kwargs)

  File "/usr/local/lib/python3.6/site-packages/requests/api.py", line 58, in request

    return session.request(method=method, url=url, **kwargs)

  File "/usr/local/lib/python3.6/site-packages/requests/sessions.py", line 508, in request

    resp = self.send(prep, **send_kwargs)

  File "/usr/local/lib/python3.6/site-packages/requests/sessions.py", line 618, in send

    r = adapter.send(request, **kwargs)

  File "/usr/local/lib/python3.6/site-packages/requests/adapters.py", line 508, in send

    raise ConnectionError(e, request=request)

requests.exceptions.ConnectionError: HTTPSConnectionPool(host='xxx.xxx.xxx', port=443): Max retries exceeded with url: / (Caused by NewConnectionError(': Failed to establish a new connection: [Errno -3] Temporary failure in name resolution',))

로컬에서는 동작하는데, AWS EC2 instance에서 저런 오류가 나는 것은 DNS resolution이 안되는 것이라고 생각해서 DNS 설정에 다음을 추가해줬다.

/etc/resolv.conf 파일에 다음과 같이 구글 DNS를 추가

nameserver 8.8.8.8

그 뒤로는 잘 동작함. 오예.


<2020년 10월 19일 추가>

서버가 재시작 되었는데, /etc/resolv.conf 파일이 자동으로 초기화된다.
찾아보니까 /sbin/dhclient-script 에서 매번 자동으로 생성되는 파일이고, /etc/sysconfig/network-scripts/ifcfg-eth0 에 다음 내용을 맨 마지막에 추가해서 구글 DNS 서버가 자동으로 추가될 수 있게 할 수 있다.

DNS1="8.8.8.8"
DNS2="기본 DNS를 입력"

참고자료: https://gunnm.tistory.com/141

Share this:

  • Twitter
  • Facebook
AWS Tips & Techs Web development pythonrequests

Post navigation

Previous post
Next post

Related Posts

How to check MySQL slow queries in real-time

2014-02-162023-07-19

Open up your console and type in the following watch -n 1 ‘mysqladmin -uroot -pyourbeautifulpassword “processlist”‘ This will display the queries that are currently under execution and will be refreshed every 1 second. Get a screenshot when you find queries that you suspect to slow down your server performance. Optimize…

Share this:

  • Twitter
  • Facebook
Read More

브라우저 호환 가능하게 해주는 normalize.css

2012-02-292023-07-19

http://nicolasgallagher.com/about-normalize-css/ 기존에 많이 쓰던 reset.css 와 비슷한데, 주석이 잘 달려있고, 기본으로 이용해도 margin padding 등이 적절하게 잡혀있어서 예쁘다

Share this:

  • Twitter
  • Facebook
Read More

Cannot start session without errors in phpMyAdmin

2013-08-212023-07-19

Error: Token Mismatch Cannot start session without errors, please check errors given in your PHP and/or webserver log file and configure your PHP installation properly. 이런 류의 오류가 계속 발생하는 현상을 겪었다. CentOS에서는 phpMyAdmin을 기본 리포지터리에서 제공하지 않는 바람에 수동 설치하느라고 애먹었다. session 폴더를 따로 지정해주지 않는 경우 “/var/lib/php/session” 폴더를…

Share this:

  • Twitter
  • Facebook
Read More

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Meta

  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org
  1. mahler83 on 공부 잘하는 과학적 방법 – Weinstein 2018.12023-07-30

    접속자가 갑자기 늘어서 홈페이지가 오동작을 했습니다. 시간이 지나면 나아질 것 같습니다.

  2. SkyHigh on 공부 잘하는 과학적 방법 – Weinstein 2018.12023-07-30

    PC에선 잘 보이는데 모바일(아이폰)에선 한번 보이고 이후부턴 계속 나오질 않네요. 뭔가 문제가 있어보입니다. 한번 확인해봐주세요

  3. mahler83 on DadGPT 한자능력검정시험 교재 4급II (자체제작)2023-07-19

    참고로 이번 주가 어문회 시험 신청 기간입니다. 좋은 결과 있으시길!

  4. Jin on DadGPT 한자능력검정시험 교재 4급II (자체제작)2023-07-19

    감사합니다~ 어이 말고 재가 해야 겠어요~

  5. mahler83 on GPT에게 한의사 국시를 풀게 했더니 57% 정답률 – 2023.32023-06-14

    안녕하세요, 댓글이 스팸필터에 걸려있어 뒤늦게 확인했습니다. 트위터에서 멘션이나 DM주셔도 되는데 번거로운 방식을 선택하신 이유가 궁금하네요. 일단 메일 드리겠습니다.

  • 3D Printing
  • Academic writing
  • Adsense
  • AI
  • AWS
  • Creativity
  • DIY
  • favorites
  • Gaming
  • Generative AI
  • hands-on
  • Home Assistant
  • Ideas
  • IT
  • Lab Stuff
  • Large language model
  • Law
  • Machine Learning
  • Medical Education
  • Medicine
  • My Thoughts
  • Neuroscience
  • Parenting
  • Pedagogy
  • Pharmacology
  • PHP
  • PokemonGo
  • Precision medicine
  • Reasoning
  • Science
  • Social studies
  • Statistics and Math
  • Tips & Techs
  • Twitter API
  • Ubuntu
  • Uncategorized
  • Web development
  • Web News
©2023 mahler83 blog v2 | WordPress Theme by SuperbThemes