PHP Laravel: No connection could be made because the target machine actively refused it
I changed the ip address specified in the homestead.yaml from localhost to 192.168.10.10. Then I ran homestead provision
and that seemed to fix the problem. The host machine cannot resolve localhost or 127.0.0.1 because that is already mapped to itself.
SQLSTATE[HY000] [2002] No Connection Could Be Made
change port to DB_PORT=3306
the
run the following commands
1.php artisan config:clear
2.php artisan cache:clear
No connection could be made because the target machine actively refused it. [tcp://127.0.0.1:6037]
The redis server was not started and the port number was wrong in my env file
Laravel: SQLSTATE HY000 2002 No connection could be made because the target machine actively refused it
Use these default settings in your .env file:
DB_HOST=127.0.0.1
DB_PORT=33060
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret
Also, be sure homestead
database is created.
The thing is .env
settings override database.php
ones.
Documentation
Email verification. No connection could be made because the target machine actively refused it
Solved it!
I just change the port and encryption
MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=25
MAIL_USERNAME=e9a7e9d32adaf9
MAIL_PASSWORD=58b926579ce74d
MAIL_FROM_ADDRESS=from@example.com
MAIL_FROM_NAME=Example
MAIL_ENCRYPTION=tls
ERROR: SQLSTATE[HY000] [2002] No connection could be made because the target machine actively refused it
If the WAMP icon is Orange then one of the services has not started.
In your case it looks like MySQL has not started as you are getting the message that indicates there is no server running and therefore listening for requests.
Look at the mysql log and if that tells you nothing look at the Windows event log, in the Windows -> Applications
section. Error messages in there are pretty good at identifying the cause of MySQL failing to start.
Sometimes this is caused by a my.ini file from another install being picked up by WAMPServers MySQL, normally in the \windows or \windows\system32 folders. Do a search for 'my.ini' and 'my.cnf' and if you find one of these anywhere outside of the \wamp.... folder structure then delete it, or at least rename it so it wont be found. Then restart the MySQL service.
Related Topics
Regular Expression: Find Range Except for One Letter or a Range
Single Result from Sum with MySQLi
Simulate PHP Array Language Construct or Parse with Regexp
PHP - Fastest Way to Check Presence of Text in Many Domains (Above 1000)
Warning: MySQL_Num_Rows() Expects Parameter 1 to Be Resource, Boolean Given
HTML Purifier: Removing an Element Conditionally Based on Its Attributes
What Is the Best PHP Dom 2 Array Function
PHP MySQL - When Is the Best Time to Disconnect from the Database
How to Remove an HTML Element Using the Domdocument Class
How to Use Date() in Doctrine 2 Dql
Incrementing Numbers Starting from 0000 in PHP
How to Change the Sequence of 'Joins' in Cakephp
Using PHP Code in Smarty Tpl File
PHP Loop; How to Print Each Result and Delay It for a Second Before Echoing Another Result