# Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) when trying to connect

**URL:** <https://community.localwp.com/t/cant-connect-to-local-mysql-server-through-socket-var-run-mysqld-mysqld-sock-2-when-trying-to-connect/50431>\
**Category:** Support\
**Tags:** linux-ubuntu, mysql\
**Created:** [June 7, 2025, 10:22am UTC](https://community.localwp.com/t/cant-connect-to-local-mysql-server-through-socket-var-run-mysqld-mysqld-sock-2-when-trying-to-connect/50431 "2025-06-07T10:22:14Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![matei](https://avatars.discourse-cdn.com/v4/letter/m/e495f1/32.png) [@matei](https://community.localwp.com/u/matei)\
**Post date:** [June 7, 2025, 10:22am UTC](https://community.localwp.com/t/cant-connect-to-local-mysql-server-through-socket-var-run-mysqld-mysqld-sock-2-when-trying-to-connect/50431/1 "2025-06-07T10:22:14Z")

</div>

### What issue or error are you experiencing?

Hello,  
I am using Localwp on my Linux Mint 21.3 Cinnamon. I want to make a backup of the WordPress website I have been working on using Duplicator plugin. When the backup tried to build, I get the below error message posted by Duplicator:

```auto
Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) when trying to connect

```

Thank you for helping me,  
Matei

* * *

### What steps can be taken to replicate the issue? Feel free to include screenshots, videos, etc

here is the entire Duplicator log report:

```auto
********************************************************************************
DUPLICATOR-LITE PACKAGE-LOG: June 7, 2025 10:04 am
NOTICE: Do NOT post to public sites or forums 
********************************************************************************
VERSION:	1.5.12
WORDPRESS:	6.8.1
PHP INFO:	8.1.29 | SAPI: fpm-fcgi
SERVER: nginx/1.26.1 
PHP TIME LIMIT: (0) no time limit imposed 
PHP MAX MEMORY: 4294967296 (256M default) 
MEMORY STACK: 10MB

********************************************************************************
DATABASE:
********************************************************************************
BUILD MODE: MYSQLDUMP
MYSQLTIMEOUT: 5000
MYSQLDUMP: Is Supported
MYSQL DUMP ERROR 2

==================================================================================
DUPLICATOR ERROR
Please try again! If the error persists see the Duplicator 'Help' menu.
---------------------------------------------------------------------------------
MESSAGE:
	Shell mysql dump error. Change SQL Mode to the "PHP Code" in the Duplicator > Settings > Backups.
DETAILS:
	mysqldump: Got error: 2002: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) when trying to connect
/* Duplicator WordPress Timestamp: 2025-06-07 10:04:33*/
/* DUPLICATOR_MYSQLDUMP_EOF */
TRACE:
	 1. class.pack.database.php : error (608)
	 2. class.pack.database.php : mysqlDump (230)
	 3. class.pack.php : build (1378)
	 4. ctrl.package.php : runZipBuild (89)
	 5. class-wp-hook.php : duplicator_package_build (324)
	 6. class-wp-hook.php : apply_filters (348)
	 7. plugin.php : do_action (517)
	 8. admin-ajax.php : do_action (192)
==================================================================================

==================================================================================
DUPLICATOR ERROR
Please try again! If the error persists see the Duplicator 'Help' menu.
---------------------------------------------------------------------------------
MESSAGE:
	Runtime error in DUP_Database::Build. Shell mysql dump error. Change SQL Mode to the "PHP Code" in the Duplicator > Settings > Backups.
DETAILS:
	Exception: Exception: Shell mysql dump error. Change SQL Mode to the "PHP Code" in the Duplicator > Settings > Backups. in /home/matei/Local Sites/brent/app/public/wp-content/plugins/duplicator/classes/class.logging.php:301
Stack trace:
#0 /home/matei/Local Sites/brent/app/public/wp-content/plugins/duplicator/classes/package/class.pack.database.php(608): DUP_Log::error('Shell mysql dum...', 'mysqldump: Got ...', 1)
#1 /home/matei/Local Sites/brent/app/public/wp-content/plugins/duplicator/classes/package/class.pack.database.php(230): DUP_Database->mysqlDump('/usr/bin/mysqld...')
#2 /home/matei/Local Sites/brent/app/public/wp-content/plugins/duplicator/classes/package/class.pack.php(1378): DUP_Database->build(Object(DUP_Package), 1)
#3 /home/matei/Local Sites/brent/app/public/wp-content/plugins/duplicator/ctrls/ctrl.package.php(89): DUP_Package->runZipBuild()
#4 /home/matei/Local Sites/brent/app/public/wp-includes/class-wp-hook.php(324): duplicator_package_build('')
#5 /home/matei/Local Sites/brent/app/public/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters('', Array)
#6 /home/matei/Local Sites/brent/app/public/wp-includes/plugin.php(517): WP_Hook->do_action(Array)
#7 /home/matei/Local Sites/brent/app/public/wp-admin/admin-ajax.php(192): do_action('wp_ajax_duplica...')
#8 {main}
TRACE:
	 1. class.pack.database.php : error (259)
	 2. class.pack.php : build (1378)
	 3. ctrl.package.php : runZipBuild (89)
	 4. class-wp-hook.php : duplicator_package_build (324)
	 5. class-wp-hook.php : apply_filters (348)
	 6. plugin.php : do_action (517)
	 7. admin-ajax.php : do_action (192)
==================================================================================

```

* * *

### System Details

- **Local Version:** Version 9.2.4+6788

- **Operating System (OS) and OS version:** Linux Mint 21.3 Cinnamon

* * *

### Local Logs

Attach your Local Logs here ([Help Doc - Retrieving Local’s Log](https://localwp.com/help-docs/troubleshooting/retrieving-locals-log-file/))  
[local-lightning.log](https://community.localwp.com/uploads/short-url/rq2buXxwWyDYQAH2bbtxe2c37P0.log) (343.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.

---

<div class="post-metadata">

**Author:** ![Nick-B](https://sea1.discourse-cdn.com/flex019/user_avatar/community.localwp.com/nick-b/32/16140_2.png) [@Nick-B](https://community.localwp.com/u/Nick-B)\
**Post date:** [June 9, 2025, 1:29pm UTC](https://community.localwp.com/t/cant-connect-to-local-mysql-server-through-socket-var-run-mysqld-mysqld-sock-2-when-trying-to-connect/50431/2 "2025-06-09T13:29:27Z")

</div>

Hi @matei

Have you tried changing your Router Mode?

[Router Mode](https://localwp.com/help-docs/advanced/router-mode/)

You might also check if you have any developer applications or security applications that could be interfering.

As a couple of workarounds, you can always use Local’s native export feature to save a zip backup copy of the site. Or copy the Local Site files directly. For another plugin option, WP Migrate Lite is free and can take a full site export and save it as a zip as well.

> **[Backup a Local Site](https://localwp.com/help-docs/getting-started/how-to-backup-a-local-site/)**
>
> Learn how to back up your Local Sites to avoid data loss and protect your hard work.

> **[WP Migrate Lite – WordPress Migration Made Easy](https://wordpress.org/plugins/wp-migrate-db/)**
>
> Migrate your database. Export full sites including media, themes, and plugins. Find and replace content with support for serialized data.

---

<div class="post-metadata">

**Author:** ![matei](https://avatars.discourse-cdn.com/v4/letter/m/e495f1/32.png) [@matei](https://community.localwp.com/u/matei)\
**Post date:** [June 9, 2025, 1:48pm UTC](https://community.localwp.com/t/cant-connect-to-local-mysql-server-through-socket-var-run-mysqld-mysqld-sock-2-when-trying-to-connect/50431/3 "2025-06-09T13:48:21Z")

</div>

Hi Nick, Yes, I can only start my website using localhost. The Site Domain does not even load the website. It does not connect at all. Please see message I get when switching to Site Domain.  
Thank you

 ![image](https://us1.discourse-cdn.com/flex019/uploads/lwpforums/original/3X/c/4/c49afb7c1ac35236f9a32e089482d1a9a3343e66.png)

 ![image](https://us1.discourse-cdn.com/flex019/uploads/lwpforums/original/3X/9/8/98e103b56cd9af976b7f975d82949a6bd6e938c1.png)

---

<div class="post-metadata">

**Author:** ![matei](https://avatars.discourse-cdn.com/v4/letter/m/e495f1/32.png) [@matei](https://community.localwp.com/u/matei)\
**Post date:** [June 9, 2025, 1:49pm UTC](https://community.localwp.com/t/cant-connect-to-local-mysql-server-through-socket-var-run-mysqld-mysqld-sock-2-when-trying-to-connect/50431/4 "2025-06-09T13:49:38Z")

</div>

Thanks Nick for the suggested backup options. I guess, on all options, I have to backup the database separately. Am I correct?

---

<div class="post-metadata">

**Author:** ![Nick-B](https://sea1.discourse-cdn.com/flex019/user_avatar/community.localwp.com/nick-b/32/16140_2.png) [@Nick-B](https://community.localwp.com/u/Nick-B)\
**Post date:** [June 9, 2025, 1:50pm UTC](https://community.localwp.com/t/cant-connect-to-local-mysql-server-through-socket-var-run-mysqld-mysqld-sock-2-when-trying-to-connect/50431/5 "2025-06-09T13:50:29Z")

</div>

We had another Linux Mint user with the same issue here recently in case this is helpful in troubleshooting:

> [@Has anyone been able to get Site Domains working on Linux Mint 22.1 Cinnamon?](https://community.localwp.com/t/has-anyone-been-able-to-get-site-domains-working-on-linux-mint-22-1-cinnamon/50421/2):
>
> Thanks for your report, logs and the steps you’ve tried so far, @alonsodude. If libcap2-bin is installed on your system (Local’s installer should have added it for you), Local will attempt to run setcap on the nginx binary after checking with getcap if that’s needed; you shouldn’t need to do it manually, but it’s great that you’ve confirmed with getcap that capabilities seem correct. Do you have AppArmor or anything else that might restrict services on port 80? sudo aa-status should tell you …

If you need to stay on Localhost would the workaround options help out for now?

---

<div class="post-metadata">

**Author:** ![matei](https://avatars.discourse-cdn.com/v4/letter/m/e495f1/32.png) [@matei](https://community.localwp.com/u/matei)\
**Post date:** [June 9, 2025, 2:12pm UTC](https://community.localwp.com/t/cant-connect-to-local-mysql-server-through-socket-var-run-mysqld-mysqld-sock-2-when-trying-to-connect/50431/6 "2025-06-09T14:12:54Z")

</div>

Thanks Nick

> [@Has anyone been able to get Site Domains working on Linux Mint 22.1 Cinnamon?](https://community.localwp.com/t/has-anyone-been-able-to-get-site-domains-working-on-linux-mint-22-1-cinnamon/50421/2):
>
> sudo aa-status

`aa-status` gave this output below. But changing `unprivileged_port_start=0` seems to have solved the Site Domain issue. I’ll investigate further if needed related to the backup solutions. This was very helpful Nick. Thank you.

```auto
$ sudo aa-status
[sudo] password for matei:          
apparmor module is loaded.
39 profiles are loaded.
37 profiles are in enforce mode.
   /usr/bin/evince
   /usr/bin/evince-previewer
   /usr/bin/evince-previewer//sanitized_helper
   /usr/bin/evince-thumbnailer
   /usr/bin/evince//sanitized_helper
   /usr/bin/evince//snap_browsers
   /usr/bin/man
   /usr/bin/redshift
   /usr/lib/NetworkManager/nm-dhcp-client.action
   /usr/lib/NetworkManager/nm-dhcp-helper
   /usr/lib/connman/scripts/dhclient-script
   /usr/lib/cups/backend/cups-pdf
   /usr/lib/lightdm/lightdm-guest-session
   /usr/lib/lightdm/lightdm-guest-session//chromium
   /usr/sbin/cups-browsed
   /usr/sbin/cupsd
   /usr/sbin/cupsd//third_party
   /{,usr/}sbin/dhclient
   libreoffice-senddoc
   libreoffice-soffice//gpg
   libreoffice-xpdfimport
   lsb_release
   man_filter
   man_groff
   nvidia_modprobe
   nvidia_modprobe//kmod
   tcpdump
   ubuntu_pro_apt_news
   ubuntu_pro_esm_cache
   ubuntu_pro_esm_cache//apt_methods
   ubuntu_pro_esm_cache//apt_methods_gpgv
   ubuntu_pro_esm_cache//cloud_id
   ubuntu_pro_esm_cache//dpkg
   ubuntu_pro_esm_cache//ps
   ubuntu_pro_esm_cache//ubuntu_distro_info
   ubuntu_pro_esm_cache_systemctl
   ubuntu_pro_esm_cache_systemd_detect_virt
2 profiles are in complain mode.
   libreoffice-oosplash
   libreoffice-soffice
0 profiles are in kill mode.
0 profiles are in unconfined mode.
2 processes have profiles defined.
2 processes are in enforce mode.
   /usr/sbin/cups-browsed (1428) 
   /usr/sbin/cupsd (1112) 
0 processes are in complain mode.
0 processes are unconfined but have a profile defined.
0 processes are in mixed mode.
0 processes are in kill mode.

```

---

<div class="post-metadata">

**Author:** ![Nick-B](https://sea1.discourse-cdn.com/flex019/user_avatar/community.localwp.com/nick-b/32/16140_2.png) [@Nick-B](https://community.localwp.com/u/Nick-B)\
**Post date:** [June 9, 2025, 2:13pm UTC](https://community.localwp.com/t/cant-connect-to-local-mysql-server-through-socket-var-run-mysqld-mysqld-sock-2-when-trying-to-connect/50431/7 "2025-06-09T14:13:40Z")

</div>

Glad to hear that @matei! Thank you for following up and letting us know.

---

<div class="post-metadata">

**Author:** ![system](https://sea1.discourse-cdn.com/flex019/user_avatar/community.localwp.com/system/32/1_2.png) [@system](https://community.localwp.com/u/system)\
**Post date:** [June 11, 2025, 2:13am UTC](https://community.localwp.com/t/cant-connect-to-local-mysql-server-through-socket-var-run-mysqld-mysqld-sock-2-when-trying-to-connect/50431/8 "2025-06-11T02:13:44Z")

</div>

This topic was automatically closed 36 hours after the last reply. New replies are no longer allowed.
