Laravel php artisan migrate connection refused - php

I am running Laravel 5 with PHP 7.0.6. When I run the php artisan update command, I get the following error:
[PDOException]
SQLSTATE[HY000] [2002] Connection refused
This is obviously database related. This happens on a production machine I have as well as local environment. My site is working in both environments.
Does anyone understand this error? Thanks.

You are missing the PHP-CLI database extension. Your site does work because your server is using the PHP-FPM (where you have the PHP extention of your database installed). But when you run php artisan migrate command you are actually executing it on the PHP-CLI.

Related

php artisan command shows Redis error when running locally instead of inside Docker container

I am using Laravel + Docker and I have a container for Redis. But when I run locally php artisan list then I get this error. I want to run this command locally (not in container), I already did composer install locally.
The reason I want to do this on my local machine is so that I could run other artisan commands on my machine (like create a new controller or model). It also helps with intelisense.
$ php artisan list
Predis\Connection\ConnectionException
php_network_getaddresses: getaddrinfo failed: No such host is known. [tcp://myapp-redis-server:6379]
If I change it to localhost, I get a different error REDIS_HOST=localhost
$ php artisan list
Predis\Connection\ConnectionException
No connection could be made because the target machine actively refused it. [tcp://localhost:6379]

Failed to connect to localhost port 9515: Connection refused

I tried laravel dusk on Laravel Framework 5.5.38 by following this https://laravel.com/docs/5.5/dusk
My environment is on windows WSL running Ubuntu 16.04
I tried this
composer require --dev laravel/dusk:"^2.0"
php artisan dusk:install
php artisan dusk
and I got this on the last one
Facebook\WebDriver\Exception\WebDriverCurlException: Curl error thrown for http POST to /session with params: {"desiredCapabilities":{"browserName":"chrome","platform":"ANY","chromeOptions":{"binary":"","args":["--disable-gpu","--headless"]}}}
Failed to connect to localhost port 9515: Connection refused
my url on local is http://crateclub.test
Does anyone encounter similar to this?
I ran into the same error while attempting to run php-webdriver with Windows WSL running Ubuntu inside of a VS Code terminal.
My fix was to switch my execution environment to PowerShell (in external Windows Terminal) and everything started working. You may need to re-install some tools such as PHP CLI and Composer, but this worked for me.

Linux laravel migrate driver not found

i have a error when i running php artisan migrate. It shows could not find driver in connection.php and connector.php , any idea to fix it ?error php artisan migrate
Try checking with 127.0.0.1 and check if you have correct db configuration.

Connecting to MAMP Path on OSX - Laravel

I have MAMP and i have successfully connected my mac's default php path to that of my MAMP. When i type command which php, it shows the path to the php version in my MAMP correctly.
When i run php artisan migrate in my terminal, it executes but i get an error
>>SQLSTATE[HY000] [2002] Connection refused (SQL: select * from information_s
chema.tables where table_schema = ecommerce and table_name = migrations)
SQLSTATE[HY000] [2002] Connection refused
Does this mean, i am not connected to the MAMP path correctly or i am still running on a different server on the mac?
PS: When i put of the stop the servers on the MAMP and run php artisan serve as well, the terminal still executes. Is running on a different server somewhere?

PDOException SQLSTATE[HY000] [2002] No such file or directory when trying to migrate

This question has already been asked multiple times, however I can't seem to get it to work anyway.
I am trying to migrate a migration I just created with laravel to my freshly created database. However, everytime I type in php artisan migrate I'm getting the above error
PDOException SQLSTATE[HY000] [2002] No such file or directory
What I have done is the following:
Create a database and a database user
CREATE DATABASE openletter CHARACTER SET utf8;
CREATE USER 'openletter'#'%' IDENTIFIED BY 'secret';
GRANT ALL PRIVILEGES ON openletter.* TO 'openletter'#'%';
Add these configs to the .env
DB_HOST=localhost
DB_DATABASE=openletter
DB_USERNAME=openletter
DB_PASSWORD=secret
Creating the migration
php artisan make:migration create_letters_table --create=letters
Migrating the migration
php artisan migrate
Then, the above listed error came.
What I tried
Restart the MySQL Service: vagrant ssh && sudo service mysqld restart
Reloading Homestead/Vagrant: vagrant reload --provision
Setting the database config in config/database.php
Many people telling others to link the mysql socket, but those people are refferencing MAMP or XAMPP or sth. else. I'm however using Homestead
What could also be the problem?
Ok guys, I fixed the issue. I'm an idiot and should be ashamed. The reason it didn't work, was because I wasn't in my vagrant machine.
After doing vagrant ssh navigating to my project cd work/OpenLetter and doing php artisan migrate it worked of course.

Categories