Issue Summary
I migrated my (non Wordpress) PHP application from Flywheel to Local. It works fine on the old Flywheel but on the new Local I get the following error when the application attempts to create a PDO instance:
Uncaught PDOException: SQLSTATE[HY000] [2002] No connection could be made because the target machine actively refused it.
Troubleshooting Questions
- Does this happen for all sites in Local, or just one in particular?
Just this one
- Are you able to create a new, plain WordPress site in Local and access it in a Browser?
Yes
Replication
I am using nginx web server, PHP version 7.3.5, MySQL 5.7.28
Below is the code used to construct the PDO instance:
public function __construct() {
$opt = array(
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_OBJ,
PDO::ATTR_EMULATE_PREPARES => FALSE,
);
$dsn = ‘mysql:host=’.DB_HOST.‘dbname=’.DB_NAME.‘;charset=’.DB_CHAR;
//$conn = new PDO(“mysql:host=”.SERVER_NAME.“;port=3307;dbname=”.DB_NAME, DB_USER, DB_PASS);
$this->pdo = new PDO($dsn, DB_USERNAME, DB_PASSWORD, $opt);
}
System Details
-
Which version of Local is being used?
6.1.5 -
What Operating System (OS) and OS version is being used?
Windows 10 professional -
Attach the Local Log. See this Community Forum post for instructions on how to do so:
local-lightning.log (154.3 KB)
Security Reminder
Local does a pretty good job of scrubbing private info from the logs and the errors it produces, however there’s always the possibility that something private can come through. Because these are public forums, always review the screenshots you are sharing to make sure there isn’t private info like passwords being displayed.