Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

MohamedTammam's avatar

Can't connect to external API using Laravel Sail

The project was working fine, suddenly I couldn't connection to Stripe nor Mailtrap APIs.

Stripe error

Could not connect to Stripe (https://api.stripe.com/v1/setup_intents). Please check your internet connection and try again. If this problem persists, you should check Stripe's service status at https://twitter.com/stripestatus, or let us know at [email protected]. (Network error [errno 6]: Could not resolve host: api.stripe.com)

Mailtrap error

Connection could not be established with host "smtp.mailtrap.io:587": stream_socket_client(): php_network_getaddresses: getaddrinfo for smtp.mailtrap.io failed: Temporary failure in name resolution

I tried to delete the containers and build them again with --no-cache

sail down -v
sail build --no-cache

But I got an error running apt-get commands because it can't reach to the endpoint.

0 likes
4 replies
Sinnbeck's avatar
Sinnbeck
Best Answer
Level 102

Try connecting to a different network, disconnect VPN or disable firewall

MohamedTammam's avatar

@Sinnbeck I don't have a VPN. And I'm using Laravel Sail with Windows WSL. And the APIs are reachable from my Windows main operating system.

MohamedTammam's avatar

I solved this by adding 1.1.1.1 and 1.0.0.1 to the DNS list. Then built the laravel.test image using docker build command. After that the docker compose build ran successfully.

Please or to participate in this conversation.