DEV Community

loading...

SQLSTATE[HY000] [2002] Connection refused

aleeshapjohn profile image aleeshapjohn ・1 min read

Hi, I am using xampp server to run my php laravel application. I used the command 'php artisan migrate' for migration and I am getting this error:

: SQLSTATE[HY000] [2002] Connection refused (SQL: select * from information_schema.tables where table_schema = testing and table_name = migrations)

My env file has been modified like this:
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=testing
DB_USERNAME=root
DB_PASSWORD=

where 'testing' is my db name.
I tried many methods and I cross verified my db credentials too.
I need help in this

Discussion

pic
Editor guide
Collapse
felipetiburcio profile image
Felipe Tiburcio

You may follow another abordation, run the docker-compose with postgres and pgadmin for interface:

version: '3.3'
services:
  db:
    image: postgres:11.2
    ports:
      - 12345:5432
    volumes:
      - ./volume:/var/lib/postgresql
    environment:
      POSTGRES_DB: test
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD: 1234
    networks:
      - development-network
  app:
    image: dpage/pgadmin4
    links:
      - db:db
    ports:
      - 90:80
    environment:
      PGADMIN_DEFAULT_EMAIL: "local@email.com"
      PGADMIN_DEFAULT_PASSWORD: "1234"
    depends_on:
      - db
    networks:
      - development-network
networks:
  development-network:
    driver: bridge

And configure as follow

DB_CONNECTION=pgsql
DB_HOST=0.0.0.0
DB_PORT=12345
DB_DATABASE=test
DB_USERNAME=postgres
DB_PASSWORD=1234
Collapse
tirthpatel1 profile image
Tirth Patel

Hey, I'm having the same error. I tried everything from changing my .env to re-installing everything up. But nothing seems to work for me. Did anyone find any solution?

Collapse
nux99 profile image
Nuga

Are you sure you activated the xampp?

Collapse
aleeshapjohn profile image
Collapse
nux99 profile image
Nuga

Hmmmm.... maybe you should setup like the first time you did the project