PHP: Guzzle 6 - cURL error 7 Connection Refused PHP: Guzzle 6 - cURL error 7 Connection Refused curl curl

PHP: Guzzle 6 - cURL error 7 Connection Refused


The issue is that your hosts file on your local machine will not impact how the docker instances map an IP to a host.

Try accessing the endpoints via the container name...


This turned out to be a relatively simple fix. The problem was the two fpm containers weren't aware of each other, and by referring to app-one.local in app-two's request, app-two was basically sending the request into the void. The fix for this was as follows:

version: '3.3'services:  nginx:    image: evild/alpine-nginx:1.9.15-openssl    container_name: nginx    volumes:      - ./app-one:/var/www/app-one/:ro      - ./app-two:/var/www/app-two/:ro      - ./nginx/conf/nginx.conf:/etc/nginx/conf/default.conf:ro      - ./nginx/conf.d:/etc/nginx/conf.d:ro      - ./certs:/etc/nginx/certs    ports:      - 80:80      - 443:443    expose:      - "80"      - "443"    depends_on:      - app-one      - app-two    environment:       TZ: "America/Los_Angeles"    # This is the fix    networks:      default:        aliases:          - app-one.local          - app-two.local  app-one:    environment:       TZ: "America/Los_Angeles"    image: joebubna/php    container_name: app-one    restart: always    volumes:      - ./app-one:/var/www/app-one    ports:      - 9000:9000    # This is the fix    networks:      - default  app-two:    environment:       TZ: "America/Los_Angeles"    image: joebubna/php    container_name: app-two    restart: always    volumes:      - ./app-two:/var/www/app-two    ports:      - 9001:9000    # This is the fix    networks:      - default  db:    image: mysql:5.6    container_name: mysql    volumes:      - db-data:/var/lib/mysql      - ./mysql/my.cnf:/etc/mysql/conf.d/ZZ-mysql.cnf:ro    environment:      MYSQL_ROOT_PASSWORD: root      MYSQL_USER: user      MYSQL_PASSWORD: password      MYSQL_DATABASE: cora      TZ: "America/Los_Angeles"    ports:      - 3306:3306    expose:      - "3306"    # This is the fix    networks:      - defaultvolumes:  db-data:# This is the fixnetworks:  default:    driver: bridge

What I ended up doing is creating an overlay network, and making the nginx container aware of each of the fpm's domain name. This allows the two containers to now send requests back and forth between each other via FQDN as opposed to IP or container ID/name. A simple thing to overlook in hindsight.


In My case URL was not valid i was missing the "https://" in start of URL. when add it was fine