0

I have a huge problem which prevents me from working on the project. I can't connect to the database with my Mac.

Error: connection refused

Actually, I'm on Xampp with the IP Address : 192.168.64.2 and MySQL run on localhost:8080 ->80(Over SSH). The Laravel project isn't inside Xampp files, just on my desktop. It run on :

Location of my project

My .env

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=80
DB_DATABASE=cartographie
DB_USERNAME=root
DB_PASSWORD=
  • port 80 and 8080 are usually associated with webservers (http), not with mysql. Are you sure you got the port right? – Shadow Feb 03 '21 at 16:29
  • Hi, Have you tried this this solution https://stackoverflow.com/questions/35394230/sqlstatehy000-2002-connection-refused-within-laravel-homestead – Sok Chanty Feb 03 '21 at 16:45

1 Answers1

0

I think I have a lead, I managed to understand the usefulness of Docker.

So I'll put the docker-compose.yml file below to enlighten you:

# For more information: https://laravel.com/docs/sail
version: '3'
services:
    laravel.test:
        build:
            context: ./vendor/laravel/sail/runtimes/8.0
            dockerfile: Dockerfile
            args:
                WWWGROUP: '${WWWGROUP}'
        image: sail-8.0/app
        ports:
            - '${APP_PORT:-80}:80'
        environment:
            WWWUSER: '${WWWUSER}'
            LARAVEL_SAIL: 1
        volumes:
            - '.:/var/www/html'
        networks:
            - sail
        depends_on:
            - mysql
            - redis
            # - selenium
    # selenium:
    #     image: 'selenium/standalone-chrome'
    #     volumes:
    #         - '/dev/shm:/dev/shm'
    #     networks:
    #         - sail
    #     depends_on:
    #         - laravel.test
    mysql:
        image: 'mysql:8.0'
        ports:
            - '${FORWARD_DB_PORT:-3306}:3306'
        environment:
            MYSQL_ROOT_PASSWORD: '${DB_PASSWORD}'
            MYSQL_DATABASE: 'cartographie'
            MYSQL_USER: 'root'
            MYSQL_PASSWORD: 'root'
            MYSQL_ALLOW_EMPTY_PASSWORD: 'yes'
        volumes:
            - 'sailmysql:/var/lib/mysql'
        networks:
            - sail
    redis:
        image: 'redis:alpine'
        ports:
            - '${FORWARD_REDIS_PORT:-6379}:6379'
        volumes:
            - 'sailredis:/data'
        networks:
            - sail
    # memcached:
    #     image: 'memcached:alpine'
    #     ports:
    #         - '11211:11211'
    #     networks:
    #         - sail
    mailhog:
        image: 'mailhog/mailhog:latest'
        ports:
            - 1025:1025
            - 8025:8025
        networks:
            - sail
networks:
    sail:
        driver: bridge
volumes:
    sailmysql:
        driver: local
    sailredis:
        driver: local

.env

APP_NAME="Agents Centrimex"
APP_ENV=local
APP_KEY=base64:WKnFZG6Qz2rEsYY+kk9kIl2Fw8l5HBa97edgqqjx4d0=
APP_DEBUG=true
APP_URL=http://127.0.0.1:8000

LOG_CHANNEL=stack
LOG_LEVEL=debug

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=cartographie
DB_USERNAME=root
DB_PASSWORD=root

BROADCAST_DRIVER=log
CACHE_DRIVER=file
QUEUE_CONNECTION=sync
SESSION_DRIVER=database
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.office365.com
MAIL_PORT=587
MAIL_USERNAME=support@centrimex.com
MAIL_PASSWORD=Vitrolles13127
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS=support@centrimex.com
MAIL_FROM_NAME="${APP_NAME}"

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

PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1

MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
Joundill
  • 6,828
  • 12
  • 36
  • 50