<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Python SDK connection error: socket.gaierror: [Errno 11004] getaddrinfo failed in Splunk Dev</title>
    <link>https://community.splunk.com/t5/Splunk-Dev/Python-SDK-connection-error-socket-gaierror-Errno-11004/m-p/238321#M3022</link>
    <description>&lt;P&gt;I am having the same error: "gaierror: [Errno 11004] getaddrinfo failed"&lt;/P&gt;

&lt;P&gt;However, none of the suggestions here have helped me resolve it. Here's my code:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;import os
import splunklib.client as client  

service = client.connect(host='https://&amp;lt;my_company_login_portal&amp;gt;.splunkcloud.com',
                            port=8089,
                            username=os.environ['SPLUNK_USERNAME'],
                            password=os.environ['SPLUNK_PASSWORD'])
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I've confirmed that:&lt;/P&gt;

&lt;OL&gt;
&lt;LI&gt;My user account has permissions to connect &lt;/LI&gt;
&lt;LI&gt;A firewall is not blocking the requests&lt;/LI&gt;
&lt;LI&gt;Port 8089 is open on splunk's end&lt;/LI&gt;
&lt;/OL&gt;

&lt;P&gt;Any direction on this error is appreciated. Thanks!&lt;/P&gt;</description>
    <pubDate>Wed, 01 Feb 2017 18:04:44 GMT</pubDate>
    <dc:creator>gestenssoro</dc:creator>
    <dc:date>2017-02-01T18:04:44Z</dc:date>
    <item>
      <title>Python SDK connection error: socket.gaierror: [Errno 11004] getaddrinfo failed</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Python-SDK-connection-error-socket-gaierror-Errno-11004/m-p/238314#M3015</link>
      <description>&lt;P&gt;I am trying to connect using the example:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;import splunklib.client as client

# Create a Service instance and log in 
with client.connect(
        host="http://myhost",
        port=0000,
        username="me",
        password="my password") as conn:
    # Print installed apps to the console to verify login
    for app in conn.apps:
        print app.name
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But I am getting the following error:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Traceback (most recent call last):
  File "C:/Users/anshanno/PycharmProjects/splunkTest/splunkSDKtest.py", line 8, in &amp;lt;module&amp;gt;
    password="my password") as conn:
  File "C:\Python27\lib\site-packages\splunk_sdk-1.6.0-py2.7.egg\splunklib\client.py", line 321, in connect
    s.login()
  File "C:\Python27\lib\site-packages\splunk_sdk-1.6.0-py2.7.egg\splunklib\binding.py", line 857, in login
    cookie="1") # In Splunk 6.2+, passing "cookie=1" will return the "set-cookie" header
  File "C:\Python27\lib\site-packages\splunk_sdk-1.6.0-py2.7.egg\splunklib\binding.py", line 1201, in post
    return self.request(url, message)
  File "C:\Python27\lib\site-packages\splunk_sdk-1.6.0-py2.7.egg\splunklib\binding.py", line 1218, in request
    response = self.handler(url, message, **kwargs)
  File "C:\Python27\lib\site-packages\splunk_sdk-1.6.0-py2.7.egg\splunklib\binding.py", line 1357, in request
    connection.request(method, path, body, head)
  File "C:\Python27\lib\httplib.py", line 1053, in request
    self._send_request(method, url, body, headers)
  File "C:\Python27\lib\httplib.py", line 1093, in _send_request
    self.endheaders(body)
  File "C:\Python27\lib\httplib.py", line 1049, in endheaders
    self._send_output(message_body)
  File "C:\Python27\lib\httplib.py", line 893, in _send_output
    self.send(msg)
  File "C:\Python27\lib\httplib.py", line 855, in send
    self.connect()
  File "C:\Python27\lib\httplib.py", line 1266, in connect
    HTTPConnection.connect(self)
  File "C:\Python27\lib\httplib.py", line 832, in connect
    self.timeout, self.source_address)
  File "C:\Python27\lib\socket.py", line 557, in create_connection
    for res in getaddrinfo(host, port, 0, SOCK_STREAM):
socket.gaierror: [Errno 11004] getaddrinfo failed
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Has anyone else experienced this or know what is causing the issue?  I have replaced my connection info for obvious reasons &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;Any help is appreciated.&lt;/P&gt;</description>
      <pubDate>Tue, 16 Aug 2016 14:37:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Python-SDK-connection-error-socket-gaierror-Errno-11004/m-p/238314#M3015</guid>
      <dc:creator>anshanno</dc:creator>
      <dc:date>2016-08-16T14:37:44Z</dc:date>
    </item>
    <item>
      <title>Re: Python SDK connection error: socket.gaierror: [Errno 11004] getaddrinfo failed</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Python-SDK-connection-error-socket-gaierror-Errno-11004/m-p/238315#M3016</link>
      <description>&lt;P&gt;I believe that error means it couldn't resolve/reach your host. &lt;/P&gt;</description>
      <pubDate>Tue, 16 Aug 2016 15:58:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Python-SDK-connection-error-socket-gaierror-Errno-11004/m-p/238315#M3016</guid>
      <dc:creator>thejeffreystone</dc:creator>
      <dc:date>2016-08-16T15:58:49Z</dc:date>
    </item>
    <item>
      <title>Re: Python SDK connection error: socket.gaierror: [Errno 11004] getaddrinfo failed</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Python-SDK-connection-error-socket-gaierror-Errno-11004/m-p/238316#M3017</link>
      <description>&lt;P&gt;EDIT: I had the wrong port and my user doesn't have privileges&lt;/P&gt;

&lt;P&gt;Thanks @thejeffreystone!  Yeah, I saw that in my search before I posted here.  The solution that they gave was to use the IP address which threw the same error for me.  I probably Should have included this in my question.&lt;/P&gt;

&lt;P&gt;If it cannot find the host could that indicate an issue with permissions?&lt;/P&gt;</description>
      <pubDate>Tue, 16 Aug 2016 16:43:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Python-SDK-connection-error-socket-gaierror-Errno-11004/m-p/238316#M3017</guid>
      <dc:creator>anshanno</dc:creator>
      <dc:date>2016-08-16T16:43:12Z</dc:date>
    </item>
    <item>
      <title>Re: Python SDK connection error: socket.gaierror: [Errno 11004] getaddrinfo failed</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Python-SDK-connection-error-socket-gaierror-Errno-11004/m-p/238317#M3018</link>
      <description>&lt;P&gt;or perhaps a firewall/routing issue somewhere. I was suspecting dns when I first read it, but you already disproved that. It's been a while since I encountered that in python. I did some testing in one of the example scripts and can't get the same error. So perhaps in this context its not resolution but something else. I think it is for sure in your connection attempt. &lt;/P&gt;

&lt;P&gt;When I pass bad host names I get:&lt;/P&gt;

&lt;P&gt;for res in getaddrinfo(host, port, 0, SOCK_STREAM):&lt;BR /&gt;
        socket.gaierror: [Errno 8] nodename nor servname provided, or not known&lt;/P&gt;

&lt;P&gt;I'm using python 2.7.11 for reference and the same version of the sdk.&lt;/P&gt;

&lt;P&gt;So now I am not so sure. I tested connecting to splunk cloud and to a local instance using the .splunkrc file and the stail.py example in the sdk. &lt;/P&gt;

&lt;P&gt;I couldn't get your script to work. But I modified the info.py script provided to provide the connection info in the script. Not sure if this will format right:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;from splunklib.client import connect
from splunklib.results import ResultsReader

 # Create a Service instance and log in
service = connect(
    host='host.com',
    port=8089,
    username='admin',
    password='mypass')

content = service.info
for key in sorted(content.keys()):
    value = content[key]
    if isinstance(value, list):
        print "%s:" % key
        for item in value: print "    %s" % item
    else:
        print "%s: %s" % (key, value)

print "Settings:"
content = service.settings.content
for key in sorted(content.keys()):
    value = content[key]
    print "    %s: %s" % (key, value)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 16 Aug 2016 18:13:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Python-SDK-connection-error-socket-gaierror-Errno-11004/m-p/238317#M3018</guid>
      <dc:creator>thejeffreystone</dc:creator>
      <dc:date>2016-08-16T18:13:34Z</dc:date>
    </item>
    <item>
      <title>Re: Python SDK connection error: socket.gaierror: [Errno 11004] getaddrinfo failed</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Python-SDK-connection-error-socket-gaierror-Errno-11004/m-p/238318#M3019</link>
      <description>&lt;P&gt;haha...I was working on my response and didnt see you have found it. Glad you got it. &lt;/P&gt;</description>
      <pubDate>Tue, 16 Aug 2016 18:21:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Python-SDK-connection-error-socket-gaierror-Errno-11004/m-p/238318#M3019</guid>
      <dc:creator>thejeffreystone</dc:creator>
      <dc:date>2016-08-16T18:21:47Z</dc:date>
    </item>
    <item>
      <title>Re: Python SDK connection error: socket.gaierror: [Errno 11004] getaddrinfo failed</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Python-SDK-connection-error-socket-gaierror-Errno-11004/m-p/238319#M3020</link>
      <description>&lt;P&gt;Sorry to waste your time.  It wouldn't let me post an update because I don't have enough rep.&lt;/P&gt;</description>
      <pubDate>Tue, 16 Aug 2016 18:27:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Python-SDK-connection-error-socket-gaierror-Errno-11004/m-p/238319#M3020</guid>
      <dc:creator>anshanno</dc:creator>
      <dc:date>2016-08-16T18:27:46Z</dc:date>
    </item>
    <item>
      <title>Re: Python SDK connection error: socket.gaierror: [Errno 11004] getaddrinfo failed</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Python-SDK-connection-error-socket-gaierror-Errno-11004/m-p/238320#M3021</link>
      <description>&lt;P&gt;No waste. I learned a new way of doing something. &lt;/P&gt;</description>
      <pubDate>Tue, 16 Aug 2016 18:29:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Python-SDK-connection-error-socket-gaierror-Errno-11004/m-p/238320#M3021</guid>
      <dc:creator>thejeffreystone</dc:creator>
      <dc:date>2016-08-16T18:29:49Z</dc:date>
    </item>
    <item>
      <title>Re: Python SDK connection error: socket.gaierror: [Errno 11004] getaddrinfo failed</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Python-SDK-connection-error-socket-gaierror-Errno-11004/m-p/238321#M3022</link>
      <description>&lt;P&gt;I am having the same error: "gaierror: [Errno 11004] getaddrinfo failed"&lt;/P&gt;

&lt;P&gt;However, none of the suggestions here have helped me resolve it. Here's my code:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;import os
import splunklib.client as client  

service = client.connect(host='https://&amp;lt;my_company_login_portal&amp;gt;.splunkcloud.com',
                            port=8089,
                            username=os.environ['SPLUNK_USERNAME'],
                            password=os.environ['SPLUNK_PASSWORD'])
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I've confirmed that:&lt;/P&gt;

&lt;OL&gt;
&lt;LI&gt;My user account has permissions to connect &lt;/LI&gt;
&lt;LI&gt;A firewall is not blocking the requests&lt;/LI&gt;
&lt;LI&gt;Port 8089 is open on splunk's end&lt;/LI&gt;
&lt;/OL&gt;

&lt;P&gt;Any direction on this error is appreciated. Thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 01 Feb 2017 18:04:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Python-SDK-connection-error-socket-gaierror-Errno-11004/m-p/238321#M3022</guid>
      <dc:creator>gestenssoro</dc:creator>
      <dc:date>2017-02-01T18:04:44Z</dc:date>
    </item>
    <item>
      <title>Re: Python SDK connection error: socket.gaierror: [Errno 11004] getaddrinfo failed</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Python-SDK-connection-error-socket-gaierror-Errno-11004/m-p/238322#M3023</link>
      <description>&lt;P&gt;What is the error that you are getting?&lt;/P&gt;</description>
      <pubDate>Wed, 01 Feb 2017 18:09:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Python-SDK-connection-error-socket-gaierror-Errno-11004/m-p/238322#M3023</guid>
      <dc:creator>anshanno</dc:creator>
      <dc:date>2017-02-01T18:09:40Z</dc:date>
    </item>
    <item>
      <title>Re: Python SDK connection error: socket.gaierror: [Errno 11004] getaddrinfo failed</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Python-SDK-connection-error-socket-gaierror-Errno-11004/m-p/238323#M3024</link>
      <description>&lt;P&gt;Actually, try this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;from splunklib.client import connect as client
import os

service = client(host='https://&amp;lt;my_company_login_portal&amp;gt;.splunkcloud.com',
                         port=8089,
                         username=os.environ['SPLUNK_USERNAME'],
                         password=os.environ['SPLUNK_PASSWORD'])
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 01 Feb 2017 18:12:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Python-SDK-connection-error-socket-gaierror-Errno-11004/m-p/238323#M3024</guid>
      <dc:creator>anshanno</dc:creator>
      <dc:date>2017-02-01T18:12:18Z</dc:date>
    </item>
    <item>
      <title>Re: Python SDK connection error: socket.gaierror: [Errno 11004] getaddrinfo failed</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Python-SDK-connection-error-socket-gaierror-Errno-11004/m-p/238324#M3025</link>
      <description>&lt;P&gt;Your code is the same as what I have above. I tried it anyways. Still didn't work. &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Feb 2017 16:13:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Python-SDK-connection-error-socket-gaierror-Errno-11004/m-p/238324#M3025</guid>
      <dc:creator>gestenssoro</dc:creator>
      <dc:date>2017-02-02T16:13:30Z</dc:date>
    </item>
  </channel>
</rss>

