gaierror Errno 11003 getaddrinfo failed

0 votes

I am trying to send one email using smtp server, but I am getting this below error.

gaierror                                  Traceback (most recent call last)
<ipython-input-17-f14b0f617ec8> in <module>
     14 
     15 try:
---> 16    smtpObj = smtplib.SMTP('nadim70.na@gmail.com',25)
     17    smtpObj.sendmail(sender, receivers, message)
     18    print ("Successfully sent email")
~\anaconda3\lib\smtplib.py in __init__(self, host, port, local_hostname, timeout, source_address)
    249 
    250         if host:
--> 251             (code, msg) = self.connect(host, port)
    252             if code != 220:
    253                 self.close()
~\anaconda3\lib\smtplib.py in connect(self, host, port, source_address)
    334         if self.debuglevel > 0:
    335             self._print_debug('connect:', (host, port))
--> 336         self.sock = self._get_socket(host, port, self.timeout)
    337         self.file = None
    338         (code, msg) = self.getreply()
~\anaconda3\lib\smtplib.py in _get_socket(self, host, port, timeout)
    305             self._print_debug('connect: to', (host, port), self.source_address)
    306         return socket.create_connection((host, port), timeout,
--> 307                                         self.source_address)
    308 
    309     def connect(self, host='localhost', port=0, source_address=None):
~\anaconda3\lib\socket.py in create_connection(address, timeout, source_address)
    705     host, port = address
    706     err = None
--> 707     for res in getaddrinfo(host, port, 0, SOCK_STREAM):
    708         af, socktype, proto, canonname, sa = res
    709         sock = None
~\anaconda3\lib\socket.py in getaddrinfo(host, port, family, type, proto, flags)
    750     # and socket type values to enum constants.
    751     addrlist = []
--> 752     for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
    753         af, socktype, proto, canonname, sa = res
    754         addrlist.append((_intenum_converter(af, AddressFamily),
gaierror: [Errno 11003] getaddrinfo failed
Apr 15, 2020 in Python by akhtar
• 38,260 points
18,411 views

1 answer to this question.

0 votes

Hi@akhtar,

It most likely means the hostname of your system can't be resolved. Use this below code, it will work.

import socket
socket.getaddrinfo('localhost', 25)
answered Apr 15, 2020 by MD
• 95,460 points
I got the same error and when I put the code you put, it didn't work, it gave me the same error
Hey, @There,

Kindly share your error logs with us so that we can analyze where the mistake has happened. Hope we can resolve your query ASAP!!!

Related Questions In Python

0 votes
0 answers

"getaddrinfo failed", what does that mean?

I am getting this error when launching ...READ MORE

May 13, 2022 in Python by Kichu
• 19,040 points
978 views
0 votes
11 answers
0 votes
1 answer

Python pygame error : Failed loading libpng.dylib: dlopen(libpng.dylib, 2): image not found

Try installing libpng You can do it with ...READ MORE

answered May 31, 2019 in Python by SDeb
• 13,300 points
1,721 views
0 votes
1 answer

Error:setup script exited with error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

Hello @kartik, Try installing these packages. sudo apt-get install ...READ MORE

answered Jun 5, 2020 in Python by Niroj
• 82,840 points
7,120 views
0 votes
2 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,434 views
0 votes
1 answer
+5 votes
6 answers

Lowercase in Python

You can simply the built-in function in ...READ MORE

answered Apr 11, 2018 in Python by hemant
• 5,790 points
4,070 views
0 votes
1 answer

failed: unable to get local issuer certif icate (_ssl.c:1056)'))'

Hi@akhtar, To avoid this error, you need to ...READ MORE

answered Apr 22, 2020 in Python by MD
• 95,460 points
3,829 views
0 votes
3 answers
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP