Failed to connect docker url with PHP Unit
I found the answer here. Updated phpunit.xml:
<env name="SIMPLETEST_BASE_URL" value="http://nginx"/>
Also in my case, I was using Drupal and had trusted hosts set in my settings.php. I also had to add nginx as a trusted host.