My laravel project runs on docker, and I can browse the project with http://localhost:8000. But when it comes to sending a request to the API of this project (API and Website are in the same project and container named web_master), I get this error:
cURL error 7: Failed to connect to localhost port 8000: Connection refused (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) for http://localhost:8000/api/v1/user/register
I can send requests to other sites like google.com, but I can not send requests to the project. this is a part of my docker-compose file:
services:
mysql:
image: mysql:8.0.30
container_name: mysql_master
restart: always
environment:
MYSQL_ROOT_USER: root
MYSQL_ROOT_PASSWORD: 123
MYSQL_DATABASE: master
volumes:
- ./mysql-data:/var/lib/mysql
ports:
- '33060:3306'
networks:
- laravel_master
web:
build:
context: .
container_name: web_master
ports:
- '8000:80'
volumes:
- ./core:/var/www/app
- ./apache/default.conf:/etc/apache2/sites-enabled/000-default.conf
depends_on:
- mysql
networks:
- laravel_master
and the virtual host file:
<VirtualHost *:80>
ServerName laravel_app
DocumentRoot /var/www/app/public
<Directory /var/www/app>
AllowOverride All
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Can anybody help me?