Cant get Sonarr to work with Jackett

Sonarr version (exact version):
Mono version (if Sonarr is not running on Windows):
OS: Ubuntu 20.04
Debug logs: Unable to connect to indexer: Error: ConnectFailure (Connection refused): ‘http://<ip_address>:9117/api/v2.0/indexers/7torrents/results/torznab/api?t=caps&apikey=<api_key>’
Description of issue: I am trying to add torrent indexers to sonarr+radarr and am running into connection issues. In Jackett, when I press the test button it shows test successfull for <indexer_name>. When I add the indexer to sonarr using the Torznab URL + API key and test it I get the error above. However if I copy paste http://<ip_address>:9117/api/v2.0/indexers/7torrents/results/torznab/api?t=caps&apikey=<api_key> into my browser it returns an xml file that seems to be what should be happening. How can I fix this issue?
Full censored exception text:

Is your browser on the same machine as Sonarr? And are you using docker containers or not?
Edit: So, docker-compose based on

you’re probably mixing up cross container access.

Browser is on same machine.
So how do I stop messing up cross container access?

So the browser is on the ubuntu host, with jackett and sonarr in separate containers?

you probably need to configure in docker compose that the containers can see eachother properly. (There probably are some guides that can help you with that)

Also depends on the ip address you’re trying to use.
If you exposed Jackett on your host IP, and are now trying to connect Sonarr to it then it won’t work. The sonarr container has no notion of the outside world. It is isolated.

This is the relevant part of my docker-compose.yml if that can help:
What is missing to help the containers communicate?

Like this