My wordpress is installed and uses localhost:/run/mysqld/mysqld/socket but civicrm only works if I point to localhost

Is there a way to install civicrm through file socket ?

2 Answers 2


You can set the DSN in the civicrm.settings.php file using this format:


Use the actual word "unix" in the string to indicate sockets.

  • for sure your guidance help, however, as StackExchange members are picky, it could not being accepted as the right answer because you forget to mention the password such as: mysql://user:password@unix(/path/to/socket)/databasename.
    – user7251
    Jul 11, 2019 at 2:19
  • You're right I've updated the answer. Thanks.
    – Demerit
    Jul 11, 2019 at 3:57
  • cv, the command line of CiviCRM don't like it
    – user7251
    Jul 23, 2019 at 9:41
  • Can you post that as a separate question, and include the error message.
    – Demerit
    Jul 23, 2019 at 12:35

I believe CiviCRM does support UNIX sockets, yes. If your hostname is "localhost" and there's no port configured, MySQL defaults to a UNIX socket connection.

$ grep DSN sites/default/civicrm.settings.php
  define('CIVICRM_UF_DSN', 'mysql://vagrant:vagrant@localhost/vagrant?new_link=true');
  define('CIVICRM_DSN', 'mysql://vagrant:vagrant@localhost/vagrant?new_link=true');

And for me, cv works fine with this configuration:

$ cv api3 Contact.get
    "is_error": 0,
    "version": 3,
    "count": 25,
    "values": {
        "202": {
            "contact_id": "202",
            "contact_type": "Individual",

I did notice on a recent (Drupal, web UI) installation that CiviCRM defaulted to adding :3306 into the CIVICRM_DSN value (but not the CIVICRM_UF_DSN setting). IDK why this happened, but this might be the source of your issue?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.