Laravel 5.3 php artisan migrate not working - laravel

I'm new to laravel and I'm exploring how to do migrations. I created a new users table and when I run "php artisan migrate" it gives me "[PDOException] SQLSTATE[HY000] [2002] No connection could be made because the target machine actively refused it." . I run "composer dump-autoload" then did "composer install" but no joy. I configured my .env file like below:
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=francis
DB_USERNAME=homestead
DB_PASSWORD=secret
Mysql status:

I think MySql service is not active. You have to active MySQL service. Because it's unable to connect with DB.
Or I think disable proxy at web.config file try this.
<system.net>
<defaultProxy>
<proxy usesystemdefault="False"/>
</defaultProxy>
</system.net>

Related

Can I connect Laravel on Heroku with Awardspace database?

I added in ENV file on Heroku informations from Awardspace, because I want to connect that database with Laravel project deployed on Heroku.
I am getting error SQLSTATE[HY000] [2002] Connection refused
you have these credentials you should put it in settings -> config vars->
DATABASE_URL
DB_CONNECTION=pgsql
DB_DATABASE
DB_HOST
DB_PASSWORD
DB_PORT
DB_USERNAME
after added these credentials with database
you should run in bash php artisan migrate
and work fine
hopefully that is help you
use this command for clear cache.
php artisan optimize:clear
php artisan optimize

Connection could not be established with host mailhog :stream_socket_client()

I'm getting an error in mailhog while sending an email to new user for creating password.
Error:
Connection could not be established with host mailhog :stream_socket_client(): php_network_getaddresses: getaddrinfo failed: No such host is known.
.env config:
MAIL_MAILER=smtp
MAIL_HOST=mailhog
MAIL_PORT=1025
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS="dev#example.com"
MAIL_FROM_NAME="${APP_NAME}"
Do you use sail package for laravel? If you are using laravel sail you should set:
MAIL_HOST=mailhog
Otherwise it must be:
MAIL_HOST=localhost
Also enter a value for MAIL_FROM_ADDRESS:
MAIL_FROM_ADDRESS=a#gmail.com
In recent versions of Laravel Homestead, if you take a look at the Homestead.yml file, almost at the top you can get the IP address set for the Homestead Virtual Machine.
Copy that address to your .env file and set it instead of mailhog:
MAIL_HOST=192.168.56.56 #mailhog
Then you can access Mailhog with your browser by typing
http://192.168.56.56:8025/
This problem occurs when some changes have been made to files, specifically in .env file. I was facing the same issue and solved by this solution.
Clear cache using artisan command
php artisan cache:clear
Clear config
php artisan config:clear
Restart your server
sudo service apache2 restart
More: Try clearing browsers cache & cookies.

Laravel Homestead not working database connect

I have installed laravel homestead and run it.
But I can't run migration locally and in vagrant.
If I try to run the migration inside vagrant
cd ~/code/project/
php artisan migrate
I got an error
could not connect to server: Connection refused
Is the server running on host "127.0.0.1" and accepting TCP/IP connections on port 54320?"
If I try to run the migration locally I got a another error
PDOException::("could not find driver")
my .env file contains the same code as written in doc
DB_CONNECTION=pgsql
DB_HOST=127.0.0.1
DB_PORT=54320
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret
Maybe something I do not understand but do I need posgresql locally and inside my vagrant? Where I have to work with database locally or with vagrant?

SQLSTATE[HY000] [2002] Connection refused after update XAMPP with PHP 7.2 on mac

Everything worked fine until I update XAMPP with PHP from 7.1 to 7.2. I noticed to access phpmyadmin using this new XAMPP on mac, need port 8080 (http://localhost:8080/phpmyadmin). Is this the problem? I already tried to change DB_HOST from 127.0.0.1 to localhost but nothing works.
Here my .env looks like
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=testing
DB_USERNAME=root
DB_PASSWORD=''

Laravel not connecting to homestead database

I was developing a laravel application locally on Mac connecting to a mysql database. i recently found out about homestead and pulled my app over to Vagrant Homestead. however now im not able to connect to the mysql server on the homestead/box.
Error i recieve:
SQLSTATE[HY000] [1045] Access denied for user 'root'#'localhost' (using password: YES)
I did update my app's .env file
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=eHDatabase
DB_USERNAME=homestead
DB_PASSWORD=secret
I cleared my app's cache
php artisan cache:clear
I updated my /etc/hosts file
27.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
127.0.0.1 laravel.app
and i also removed the old mysql server running on port 3306 on 127.0.0.1.
but still recieve the connection error.
Any help would be great.
Both .env and /config/database.php are looking fine, so try to run this:
php artisan config:cache

Resources