Connecting to JIRA API using Python with proxy settings

I’m having trouble setting up a connection to JIRA using the Python API with a proxy. Here’s what I’ve tried:

jira_config = {
    'base_url': 'https://example.com/jira',
    'proxy': {
        'http': 'http://proxy.example.com:8080',
        'https': 'http://proxy.example.com:8080'
    },
    'ssl_verify': False,
    'timeout': 30
}

jira_client = JiraAPI(
    config=jira_config,
    credentials=('username', 'password'),
    validate_connection=True
)

But I’m getting this error:

APIConnectionError: Failed to establish connection
Details: HTTP Error None

Does anyone know how to properly configure the JIRA Python client to work with a proxy? I’m not sure if I’m missing something in the setup or if there’s a different approach I should be using. Any help would be appreciated!

hey gizmo, have u tried using requests library instead? sometimes it works better w/ proxies. something like this:

import requests
from requests.auth import HTTPBasicAuth

s = requests.Session()
s.proxies = {'http': 'http://proxy.example.com:8080', 'https': 'http://proxy.example.com:8080'}
s.verify = False

response = s.get('https://example.com/jira', auth=HTTPBasicAuth('username', 'password'))

might solve ur issue. good luck!

I’ve dealt with similar proxy issues when connecting to JIRA via Python. One thing that often gets overlooked is proxy authentication. If your proxy requires credentials, you’ll need to include those in your configuration. Here’s an example that worked for me:

from jira import JIRA

proxy_url = 'http://proxy_username:[email protected]:8080'

options = {
    'server': 'https://example.com/jira',
    'verify': False,
    'proxies': {
        'http': proxy_url,
        'https': proxy_url
    }
}

jira = JIRA(options, basic_auth=('jira_username', 'jira_password'))

Also, double-check that your proxy isn’t blocking outgoing connections to JIRA’s port. Sometimes IT policies can be pretty strict about these things. If you’re still stuck, try running your script with verbose logging enabled to get more detailed error information.

I’ve encountered similar issues when working with JIRA’s API through a proxy. One solution that worked for me was explicitly setting the proxy in the JIRA client constructor. Try modifying your code like this:

from jira import JIRA

options = {
    'server': 'https://example.com/jira',
    'verify': False
}

proxies = {
    'http': 'http://proxy.example.com:8080',
    'https': 'http://proxy.example.com:8080'
}

jira = JIRA(options, basic_auth=('username', 'password'), proxies=proxies)

This approach directly passes the proxy settings to the JIRA client. Also, ensure your proxy server is correctly configured to allow connections to the JIRA instance. If you’re still having trouble, check your network settings and firewall rules.