Splunk Enterprise Security

splunklib.client as client IPv6 Error

jlittiebrant
New Member

Hello,

I am attempting to access the REST api of a splunk instance through Python and am receiving an IPv6 error in parsing the URL I provided. I have pinged the url and also nslookup it and I cannot retrieve an IPv6 address. The code I am using is straight from the docs:

import splunklib.client as client
service = client.connect(host=url, port=port,
username=username, password=password)
assert isinstance(service, client.Service)

The final error message is:
~\Anaconda3\lib\site-packages\splunklib\binding.py in _spliturl(url)
1069 # Crack the given url into (scheme, host, port, path)
1070 def _spliturl(url):
-> 1071 parsed_url = urllib.parse.urlparse(url)
1072 host = parsed_url.hostname
1073 port = parsed_url.port

~\Anaconda3\lib\urllib\parse.py in urlparse(url, scheme, allow_fragments)
366 (e.g. netloc is a single string) and we don't expand % escapes."""
367 url, scheme, _coerce_result = _coerce_args(url, scheme)
--> 368 splitresult = urlsplit(url, scheme, allow_fragments)
369 scheme, netloc, url, query, fragment = splitresult
370 if scheme in uses_params and ';' in url:

~\Anaconda3\lib\urllib\parse.py in urlsplit(url, scheme, allow_fragments)
438 if (('[' in netloc and ']' not in netloc) or
439 (']' in netloc and '[' not in netloc)):
--> 440 raise ValueError("Invalid IPv6 URL")
441 if allow_fragments and '#' in url:
442 url, fragment = url.split('#', 1)

Please assist, or let me know if IPv4 is not supported with the splunk api for Python.

0 Karma

nickhills
Ultra Champion

"I have pinged the url and also nslookup it and I cannot retrieve an IPv6 address."

That could well be your issue if you are unable to resolve the URL.

Is the Splunk Server running on IPv4 or IPv6?
How is it configured in server.conf, and web.conf?
https://docs.splunk.com/Documentation/Splunk/7.2.4/Admin/ConfigureSplunkforIPv6

Splunk and the rest API is supported on both 4&6.

If my comment helps, please give it a thumbs up!
0 Karma
Get Updates on the Splunk Community!

Splunk at Cisco Live 2025: Learning, Innovation, and a Little Bit of Mr. Brightside

Pack your bags (and maybe your dancing shoes)—Cisco Live is heading to San Diego, June 8–12, 2025, and Splunk ...

Splunk App Dev Community Updates – What’s New and What’s Next

Welcome to your go-to roundup of everything happening in the Splunk App Dev Community! Whether you're building ...

The Latest Cisco Integrations With Splunk Platform!

Join us for an exciting tech talk where we’ll explore the latest integrations in Cisco + Splunk! We’ve ...