Docker Community Forums

Share and learn in the Docker community.

cURL error 7: Failed to connect to localhost port 80: Connection refused

I´m using WordPress in docker and i´m building a plugin with curl but now all curl calls (using WP-Cron plugin to check) even not my own dose not work and i get

cURL error 7: Failed to connect to localhost port 80: Connection refused

looks like i cant get out of the container, do i need to use resolve ? ,i have tryed proxy_pass but no luck

docker-compose.yml

version: "3"

services:

php:
  build: ./php/
  expose:
    - 9000
  volumes:
    - "${PROJECT_UROOT}:/var/www"
  working_dir: ${PROJECT_SROOT}
  networks:
    - server
    - database
  depends_on:
    - mysql

phpmyadmin:
  image: phpmyadmin/phpmyadmin
  ports:
    - 8080:80
  networks:
    - database
  depends_on:
    - mysql
  environment:
    PMA_HOST: mysql
  restart: always

composer:
  restart: 'no'
  image: composer/composer:php7
  command: install
  volumes:
    - "${PROJECT_UROOT}:/var/www"
  working_dir: ${PROJECT_SROOT}

nginx:
  build: ./nginx/
  ports:
    - 80:80
  volumes:
    - "${PROJECT_UROOT}:/var/www"
    - ./nginx/logs:/var/log/nginx
  networks:
    - server
  depends_on:
    - php
  restart: always

mysql:
  image: mariadb
  ports:
    - 3306:3306
  volumes:
    - ./mysql/db-data:/var/lib/mysql
  environment:
    - MYSQL_ROOT_PASSWORD=${DB_ROOT_PASSWORD}
  restart: always
  networks:
    - database

volumes:
  data:

networks:
  database:
  server:

nginx/default.conf

server {
    listen 80 default_server;
    root /var/www/public;
    index index.html index.php;

    charset utf-8;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt  { access_log off; log_not_found off; }

    access_log off;
    error_log  /var/log/nginx/error.log error;

    sendfile off;

    client_max_body_size 100m;

    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass php:9000;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_intercept_errors off;
        fastcgi_buffer_size 16k;
        fastcgi_buffers 4 16k;
    }

    location ~ /\.ht {
        deny all;
    }

        
}

I have the same problem as you. were you able to solve yours? If yes, how? thx