Cant get Sonarr to work with Jackett

Sonarr version (exact version): 2.0.0.5344
Mono version (if Sonarr is not running on Windows): 5.20.1.34
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: https://pastebin.com/k4sjb5vk

Is your browser on the same machine as Sonarr? And are you using docker containers or not?
Edit: So, docker-compose based on https://www.reddit.com/r/sonarr/comments/gjlknn/problems_connecting_jackett_and_sonarr/

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.

Yes.
This is the relevant part of my docker-compose.yml if that can help:
https://pastebin.com/5HhEjb8B
What is missing to help the containers communicate?

Like this https://www.reddit.com/r/sonarr/comments/7no699/sonarr_in_a_docker_is_not_connecting_to_a_jackett/ds3if87/