1

I am trying to connect to gmail server using POP protocol using poplib library. it fails to connect with error:socket.gaierror: [Errno -2] Name or service not known

I have network access from the machine i am running my script.

import poplib
pop_conn = poplib.POP3_SSL('pop.gmail.com',995, timeout=30)

Traceback (most recent call last):
  File "python", line 2, in <module>
socket.gaierror: [Errno -2] Name or service not known

Please help in rectifying this?

I got the gmail server name from the below link: https://support.google.com/mail/answer/7104828?hl=en&visit_id=1-636148818957220191-1947633130&rd=3

Pradeep
  • 1,057
  • 2
  • 9
  • 17
  • Can you ping `pop.gmail.com` from the machine you're running the code on? – Torxed Nov 16 '16 at 09:00
  • Lose the timeout argument and it should work – Rolf of Saxony Nov 16 '16 at 09:06
  • @Torxed: getting request timeout on ping - ping gmail-pop.l.google.com [64.233.178.108] with 32 bytes of data: Request timed out. – Pradeep Nov 16 '16 at 09:09
  • @RolfofSaxony: same error, I am able to access internet , there is no connectivity issue – Pradeep Nov 16 '16 at 09:10
  • 1
    @Pradeep_Evol Then I'm guessing your DNS server is wacky or you have no internet access. This isn't a programming error as much as it is your setup/scenario that isn't properly configured. If ping is getting a timeout - then it's an obvious sign something is wrong with the network. – Torxed Nov 16 '16 at 09:10
  • Same problem here. Tried in two computers, both with Ubuntu flavours. One succeeds another doesn't. Both are connected to the internet. – madtyn Jul 19 '18 at 08:37

0 Answers0