Fix Unable to connect to xend: Connection refused. ExpatError: no element found

The error message

Unable to connect to xend: Connection refused. Is xend running?

can be caused by a number of issues, but if your xend.log contains lines regarding syntax, such as:

[2012-01-23 11:33:37 5670] INFO (SrvDaemon:227) Xend stopped due to signal 15.
[2012-01-23 11:33:38 6427] INFO (SrvDaemon:332) Xend Daemon started
[2012-01-23 11:33:38 6427] INFO (SrvDaemon:336) Xend changeset: unavailable.
[2012-01-23 11:33:38 6427] ERROR (SrvDaemon:349) Exception starting xend (no element found: line 1, column 0)
Traceback (most recent call last):
  File "/usr/lib64/python2.6/site-packages/xen/xend/server/SrvDaemon.py", line 341, in run
    servers = SrvServer.create()
  File "/usr/lib64/python2.6/site-packages/xen/xend/server/SrvServer.py", line 251, in create
    root.putChild('xend', SrvRoot())
  File "/usr/lib64/python2.6/site-packages/xen/xend/server/SrvRoot.py", line 40, in __init__
  File "/usr/lib64/python2.6/site-packages/xen/web/SrvDir.py", line 84, in get
    val = val.getobj()
  File "/usr/lib64/python2.6/site-packages/xen/web/SrvDir.py", line 52, in getobj
    self.obj = klassobj()
  File "/usr/lib64/python2.6/site-packages/xen/xend/server/SrvNode.py", line 30, in __init__
    self.xn = XendNode.instance()
  File "/usr/lib64/python2.6/site-packages/xen/xend/XendNode.py", line 1140, in instance
    inst = XendNode()
  File "/usr/lib64/python2.6/site-packages/xen/xend/XendNode.py", line 158, in __init__
  File "/usr/lib64/python2.6/site-packages/xen/xend/XendNode.py", line 270, in _init_PPCIs
    saved_ppcis = self.state_store.load_state('ppci')
  File "/usr/lib64/python2.6/site-packages/xen/xend/XendStateStore.py", line 104, in load_state
    dom = minidom.parse(xml_path)
  File "/usr/lib64/python2.6/site-packages/_xmlplus/dom/minidom.py", line 1915, in parse
    return expatbuilder.parse(file)
  File "/usr/lib64/python2.6/site-packages/_xmlplus/dom/expatbuilder.py", line 926, in parse
    result = builder.parseFile(fp)
  File "/usr/lib64/python2.6/site-packages/_xmlplus/dom/expatbuilder.py", line 211, in parseFile
    parser.Parse("", True)
ExpatError: no element found: line 1, column 0

there is a good chance your xend database (stored, intuitively, in python syntax...) is suffering from corruption.

It is safe to remove the database but best practice to back it up so rename the directory:

# mv /var/lib/xend /var/lib/xend.bak
# /etc/init.d/xend restart


• Karen

THANK YOU so much, you just saved my butt.


Thank you so much. Your fix saved my day. It worked for me on my OVM3 server.


• Sysadmin