# ProxySQL and PXC - unable to connect to localhost with proxysql-admin

**URL:** <https://forums.percona.com/t/proxysql-and-pxc-unable-to-connect-to-localhost-with-proxysql-admin/7088>\
**Category:** Percona XtraDB Cluster 5.x\
**Created:** [July 1, 2019, 12:10pm UTC](https://forums.percona.com/t/proxysql-and-pxc-unable-to-connect-to-localhost-with-proxysql-admin/7088 "2019-07-01T12:10:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![amcalexander](https://avatars.discourse-cdn.com/v4/letter/a/278dde/32.png) [@amcalexander](https://forums.percona.com/u/amcalexander)\
**Post date:** [July 1, 2019, 12:10pm UTC](https://forums.percona.com/t/proxysql-and-pxc-unable-to-connect-to-localhost-with-proxysql-admin/7088/1 "2019-07-01T12:10:56Z")

</div>

I’ve gotten past the admin issue and can log into proxysql as admin by working through a few threads, but I’ve ran across an issue I am unable to figure out.  
Upon trying to run “sudo proxysql-admin --config-file=/etc/proxysql-admin.cnf --enable”, the ProxySQL server reports this:

ERROR 2003 (HY000): Can’t connect to MySQL server on ‘localhost’ (111)  
ERROR (line:703) : PXC connection check failed.  
– Could not connect to the PXC cluster at localhost:3306  
– Please check the PXC connection parameters and status.

My setup - 1 ProxySQL VM  
3 PXC VMs 5.7

I followed this guide, [URL][https://www.percona.com/doc/percona-xtradb-cluster/5.7/howtos/proxysql-v2.html#installing-proxysql-v2[/URL]](https://www.percona.com/doc/percona-xtradb-cluster/5.7/howtos/proxysql-v2.html#installing-proxysql-v2%5B/URL%5D), but the issue I’m finding is that there are no servers laid out to connect to and all I get is unable to connect to localhost on 3306, this is due to PXC 5.7 not running on localhost:3306, but running on 3 other servers. I’m unsure how to tell ProxySQL about these servers so the proxysql-admin utility knows about them. This utility doesn’t seem to allow me to budge any further in this install until it knows about the PXC servers, which it’s not actually doing anything about. I’m sure I’ve missed a step in the 5 or so install docs I’ve been fumbling through. Is there one solid source that goes over this in depth? Seems to be a lot of “gotchas” in terms of things to double check, but a lot of these are spread across multiple write-ups from Percona.

---

<div class="post-metadata">

**Author:** ![amcalexander](https://avatars.discourse-cdn.com/v4/letter/a/278dde/32.png) [@amcalexander](https://forums.percona.com/u/amcalexander)\
**Post date:** [July 1, 2019, 1:27pm UTC](https://forums.percona.com/t/proxysql-and-pxc-unable-to-connect-to-localhost-with-proxysql-admin/7088/2 "2019-07-01T13:27:57Z")

</div>

Sorry, I forgot the config:

# proxysql admin interface credentials.

export PROXYSQL\_DATADIR=‘/var/lib/proxysql’  
export PROXYSQL\_USERNAME=‘admin’  
export PROXYSQL\_PASSWORD=‘SAVED-Password’  
export PROXYSQL\_HOSTNAME=‘localhost’  
export PROXYSQL\_PORT=‘6032’

# PXC admin credentials for connecting to pxc-cluster-node.

export CLUSTER\_USERNAME=‘sbuser’  
export CLUSTER\_PASSWORD=‘SAVED-Password’  
export CLUSTER\_HOSTNAME=‘localhost’  
export CLUSTER\_PORT=‘3306’

# proxysql monitoring user. proxysql admin script will create this user in pxc to monitor pxc-nodes.

export MONITOR\_USERNAME=‘proxysql’  
export MONITOR\_PASSWORD=‘SAVED-Password’

# Application user to connect to pxc-node through proxysql

export CLUSTER\_APP\_USERNAME=‘proxysql\_user’  
export CLUSTER\_APP\_PASSWORD=‘SAVED-Password’

# ProxySQL hostgroup IDs

export WRITER\_HOSTGROUP\_ID=‘10’  
export READER\_HOSTGROUP\_ID=‘11’  
export BACKUP\_WRITER\_HOSTGROUP\_ID=‘12’  
export OFFLINE\_HOSTGROUP\_ID=‘13’

# ProxySQL read/write configuration mode.

export MODE=“singlewrite”

# max\_connections default (used only when INSERTing a new mysql\_servers entry)

export MAX\_CONNECTIONS=“1000”

# Determines the maximum number of writesets a node can have queued

# before the node is SHUNNED to avoid stale reads.

export MAX\_TRANSACTIONS\_BEHIND=100

# Connections to the backend servers (from ProxySQL) will use SSL

export USE\_SSL=“no”

# Determines if a node should be added to the reader hostgroup if it has

# been promoted to the writer hostgroup.

# If set to ‘yes’, then all writers (including backup-writers) are added to

# the read hostgroup.

# If set to ‘no’, then none of the writers (including backup-writers) are added.

# If set to ‘backup’, then only the backup-writers will be added to

# the read hostgroup.

export WRITERS\_ARE\_READERS=“backup”
