Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

"Could not resolve host" when trying to connect to Stripe's API

As the title says there are some DNS issues and sometimes when I try to curl inside my docker container https://api.stripe.com/v1/setup_intents it returns curl: (6) Could not resolve host: api.stripe.com. This issue does not happen if I try to curl other websites.

docker exec -it php-alpine /bin/sh

/var/www/html # curl https://api.stripe.com/v1/setup_intents
{ works. some json response }

/var/www/html # curl https://api.stripe.com/v1/setup_intents
curl: (6) Could not resolve host: api.stripe.com

/var/www/html # curl https://api.stripe.com/v1/setup_intents
curl: (6) Could not resolve host: api.stripe.com

/var/www/html # curl https://api.stripe.com/v1/setup_intents
{ works. some json response }

/var/www/html # curl https://api.stripe.com/v1/setup_intents
curl: (6) Could not resolve host: api.stripe.com

/var/www/html # curl https://api.stripe.com/v1/setup_intents
{ works. some json response }

and so on...

However when I exit my docker image this issue does not happen. I can curl that address hundreds of times on my Ubuntu system (working on WSL) and it has never gave me any error before.

I tried to curl that address simultaneously from my local Ubuntu system, and from the docker image and while everything worked on Ubuntu, I was still getting the same error in the docker image.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

login to docker container and open this file /etc/resolv.conf and add this line inside:

nameserver 8.8.8.8

or just run this inside container:

echo "nameserver 8.8.8.8" > /etc/resolv.conf
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading