Docker & Laravel - Illuminate\Database\QueryException SQLSTATE[HY000] [2002] Connection refused

Viewed 32

Trying to get a Laravel - docker project running locally (Windows 11) and getting the following error when running 'php artisan migrate' screenshot of error message here

I've tried changing the DB_HOST name in my .env file to the name of my mysql container, updating my user credentials in database.php, nothing has worked so far, unsure where to go from here, any assistance would be greatly appreciated!

Here is the error:

Illuminate\Database\QueryException

  SQLSTATE[HY000] [2002] Connection refused (SQL: select * from information_schema.tables where table_schema = honeyguide and table_name = migrations and table_type = 'BASE TABLE')

docker-compose.yml:

version: '3'
services:
  php:
    image: webdevops/php-nginx:8.0-alpine
    working_dir: /app
    environment:
      - WEB_DOCUMENT_ROOT=/app/public
    ports:
      - "80:80"
    volumes:
      - ./code:/app:rw,cached
  mysql:
      image: mysql:8
      ports:
        - 3307:80
      volumes:
        - db:/var/lib/mysql
      environment:
        - MYSQL_ROOT_PASSWORD=*****
        - MYSQL_PASSWORD=*****
        - MYSQL_USER=honeyguide
        - MYSQL_DATABASE=honeyguide

volumes:
  db:

.env file

APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:7OVBTSdMj/Cu1axA/SemgoF+sk17iR1oWwdj7xVpv+E=
APP_DEBUG=true
APP_URL=http://localhost

LOG_CHANNEL=stack
LOG_DEPRECATIONS_CHANNEL=null
LOG_LEVEL=debug

DB_CONNECTION=mysql
DB_HOST=mysql
DB_PORT=3307
DB_DATABASE=honeyguide
DB_USERNAME=honeyguide
DB_PASSWORD=******

BROADCAST_DRIVER=log
CACHE_DRIVER=file
FILESYSTEM_DISK=local
QUEUE_CONNECTION=sync
SESSION_DRIVER=cookie
SESSION_LIFETIME=120

MEMCACHED_HOST=127.0.0.1

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_MAILER=smtp
MAIL_HOST=smtp.sendgrid.net
MAIL_PORT=587
MAIL_USERNAME=apikey
MAIL_PASSWORD=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
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS="*******"
MAIL_FROM_NAME=HONEYGUIDE

AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=
AWS_USE_PATH_STYLE_ENDPOINT=false

PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_HOST=
PUSHER_PORT=443
PUSHER_SCHEME=https
PUSHER_APP_CLUSTER=mt1

VITE_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
VITE_PUSHER_HOST="${PUSHER_HOST}"
VITE_PUSHER_PORT="${PUSHER_PORT}"
VITE_PUSHER_SCHEME="${PUSHER_SCHEME}"
VITE_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"

AGENT_DOMAINS='(protea.localhost|sheraton.localhost)'
ADMIN_URL=localhost
0 Answers
Related