Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Http\Client\Socket\Exception\ConnectionException: Unable to find the socket transport "unix" #36

Open
hantsy opened this issue Mar 6, 2025 · 1 comment

Comments

@hantsy
Copy link

hantsy commented Mar 6, 2025

Check the testing codes in the PR https://github.com/hantsy/symfony-rest-sample/blob/5e7d022e62d046933ff8117a7370e3842ca9c20b/tests/Repository/PostRepositoryTestWithTestcontainers.php

Http\Client\Socket\Exception\ConnectionException: Unable to find the socket transport "unix" - did you forget to enable it when you configured PHP?

...vendor\php-http\socket-client\src\Client.php:117
@rw4lll
Copy link
Collaborator

rw4lll commented Mar 6, 2025

@hantsy I couldn't reproduce the issue. This code works well:

 $container = new PostgresContainer('16');
  $container->withPostgresDatabase('blogdb');
  $container->withPostgresUser('user');
  $container->withPostgresPassword('password');
  $container->withExposedPorts("5432");
  $container->start();

Make sure your PHP installation has php-sockets enabled. Without it, Testcontainers-PHP cannot connect to the default Docker socket (unix:///var/run/docker.sock).
See: https://www.php.net/manual/en/sockets.installation.php

If you are running Windows or don't have Unix socket support, you can try switch to TCP by setting the DOCKER_HOST environment variable:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants