Hello! I’m seeking assistance regarding the connection to the Jira Python package. I am attempting to link to our Jira server but often encounter connection issues.
Here’s the code snippet I’m using:
def connect_jira():
try:
print("Trying to connect to: %s" % server_url)
options = {'server': server_url, 'verify': False}
jira_instance = JIRA(options=options,
basic_auth=(user, passcode))
return jira_instance
except Exception as err:
options = {'server': server_url, 'verify': False}
jira_instance = JIRA(options=options,
basic_auth=(user, passcode))
print("Could not connect to Jira: %s" % err)
sys.exit()
It works occasionally, but mostly it fails with the following error:
HTTPSConnectionPool(host='my_jira_instance', port=443): Max retries exceeded with url: /rest/api/2/serverInfo (Caused by NewConnectionError('<requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x02D48450>: Failed to establish a new connection: [Errno 10061] No connection could be made because the target machine actively refused it',))
looks like a firewall or proxy issue. that errno 10061 means something’s actively blocking ur connection. if ur behind a corporate network, try adding timeout and proxy settings to ur options dict. also, ur exception handling doesn’t make sense - why create another JIRA instance in the except block? that’ll just fail too.
That error indicates the server is actively refusing your connection. I’ve encountered similar issues with corporate Jira instances behind firewalls or proxies. First, verify if your server_url is accessible by opening it in a browser. If you’re behind a firewall, you may need to configure proxy settings in your JIRA options. Additionally, confirm whether your company requires OAuth or API tokens instead of basic authentication. Lastly, consider refining your exception handling; instead of attempting to connect twice in the same block, introduce timeout parameters and a retry mechanism with exponential backoff to improve reliability.
I see you’re using verify=False - that usually means SSL certificate problems. Connection refusal errors happen when there’s a network block or Jira isn’t running properly. Before changing code, try a simple curl command or ping to see if it’s a network issue vs authentication problem. Your exception handling won’t work though - you’re creating another JIRA instance in the except block that’ll just fail again. Add a timeout parameter to your options and check if your org uses personal access tokens instead of username/password.