0

I have 3 Vuejs SPAs which use the same Laravel API setup using Sail/Selenium/Docker. I want to test each SPA from the API using Dusk but whenever I try to visit localhost with the port (http://localhost:9007) I get the following error:

Facebook\WebDriver\Exception\UnknownErrorException: unknown error: net::ERR_CONNECTION_REFUSED

I don't get the error with http://google.com or just using relative paths like / or /login.

Here is the code I am using to test:

$browser->visit('http://127.0.0.1:9007');
Tyler
  • 3,713
  • 6
  • 37
  • 63

1 Answers1

0

Depends where the app is hosted and where the test is running.

I assume both are in containers now. Containers connect to each other using their container name as host name. So change $browser->visit('http://127.0.0.1:9007'); to $browser->visit('http://[target_container_name]:9007');

If you want to connect from inside a container to your host machine you need host.docker.internal.

From container to container it's the container name, e.g. http://php_container

From host machine to container, you can just use localhost, as long as you added your port mapping in docker-compose.yml

online Thomas
  • 8,864
  • 6
  • 44
  • 85