LDUBBS
LDUBBS

Reputation: 603

How to connect to MySQL on a different port

I ran php artisan serve artisan command on a Laravel app, it runs on port 8000. However, I get a MySQL error when hitting a table: No connection could be made because the target machine actively refused it.

My .env

DB_HOST=locahost
DB_PORT=3306

Upvotes: 1

Views: 1060

Answers (2)

Hedayatullah Sarwary
Hedayatullah Sarwary

Reputation: 2834

Sometimes this problem occurs because of cache, run the below command and try to clean your configuration cache:

php artisan config:clear

And if your problem is not solved try to change your DB_HOST=localhost in your .env file to DB_HOST=127.0.0.1.

Upvotes: 1

damask
damask

Reputation: 555

Try changing to DB_HOST=127.0.0.1

Upvotes: 2

Related Questions