Find the Best Cosmetic Hospitals

Explore trusted cosmetic hospitals and make a confident choice for your transformation.

“Invest in yourself — your confidence is always worth it.”

Explore Cosmetic Hospitals

Start your journey today — compare options in one place.

Laravel 5.5 php artisan migrate error in Ubuntu: SQLSTATE[HY000] [2002] Connection refused

How I got this error?
Ans: I was running php artisan migrate command in /opt/lampp/htdocs/project_dir

What was the error?
ubuntu@ip-ip_addr:/opt/lampp/htdocs/project_dir$ php artisan migrate
In Connection.php line 664:

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

In Connector.php line 67:

SQLSTATE[HY000] [2002] Connection refused

Screenshot of the error:

Solution:
1. Open .env file
2. Change the DB_HOST=127.0.0.1 to DB_HOST=localhost
3. Make sure the port number, db name, username and password is correctly mention in the .env before saving it
4. Save the .env file then run command: sudo artisan config:cache
5. Now, run command: php artisan migrate

Output after applying the solution:

Thanks for reading. I hope you enjoyed the article!

Find Trusted Cardiac Hospitals

Compare heart hospitals by city and services — all in one place.

Explore Hospitals
Say goodbye to the hassles of bike ownership! MotoShare.in offers affordable rentals, whether you need a scooter for errands, a bike for a road trip, or a reliable ride to explore new cities.

Related Posts

What is Laravel and use cases of Laravel?

What is Laravel? Laravel is an open-source, free PHP web framework designed for the development of web applications following the model-view-controller (MVC) architectural pattern. It was generated…

Read More

Complete guide of Laravel certification courses, tutorials & training

What is Laravel Laravel is a reliable and simple to use open-source PHP framework. It adheres to the model-view-controller pattern of design. Laravel makes use of pre-existing…

Read More

Top 100 laravel interview questions and answers

1) What is Laravel? Laravel is an open-source widely used PHP framework. The platform was intended for the development of web application by using MVC architectural pattern….

Read More

[SOLVED] Laravel : Supervisor FATAL/BACKOFF Exited too quickly (process log may have details)

Problem I’m trying to use Laravel queues with a supervisor but the service is not working properly. When I try to check status:$ sudo supervisorctl status$ laravel-worker:laravel-worker_00:…

Read More

How to Login with Token in Laravel PHP Framework?

How to Login with Token in Laravel PHP Framework? Step 1. Create a new Project, so write down the following command on Git Bash: Step 2. Move…

Read More

Directory Structure Of Laravel Application

devopsschool – This is Project Folder app – The app directory contains the core code of your application. bootstrap – The bootstrap directory contains the app.php file…

Read More