无法与ngrok共享PHP PDO项目:FATAL ERROR

FOUND SOLUTION : I had to add the port and replace localhost by 127.0.0.1 in the DSN

I have a problem with all my PHP websites connected with PDO when I try to share them with ngrok : I get a PDO exception but all works fine in local...

Fatal error: Uncaught PDOException: SQLSTATE[HY000] [2002] No such file or directory in /Applications/MAMP/htdocs/cours/PHP/chatbox/Final/php/bdd.class.php:12 Stack trace: #0 /Applications/MAMP/htdocs/cours/PHP/chatbox/Final/php/bdd.class.php(12): PDO->__construct('mysql:host=loca...', 'root', 'root', Array) #1 /Applications/MAMP/htdocs/cours/PHP/chatbox/Final/php/discussion.class.php(7): BDD->__construct() #2 /Applications/MAMP/htdocs/cours/PHP/chatbox/Final/php/controller.php(31): Discussion->__construct() #3 {main} thrown in /Applications/MAMP/htdocs/cours/PHP/chatbox/Final/php/bdd.class.php on line 12

All my links are relative

Here a piece of code (very basic)

include "bdd.class.php";
include "discussion.class.php";
include "message.class.php";

And where the error is declared (in my bdd.class.php) :

$this->bdd = new PDO (
            'mysql:host=localhost;dbname=chatbox;charset=UTF8',
            'root',
            'root',
            [
                PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
                PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC
            ]
            );

Do you have any idea of how to make it work when it is shared with ngrok ?

Best