from haproxystats import HAProxyServer

class HAProxyServer:
    for b in haproxy.backends:
        print('%s: %s' % (b.name, b.status))

if i run the above code i am getting error

python3.6 hatop.py

  File "hatop.py", line 3, in <module>
    from haproxystats import HAProxyServer
ImportError: cannot import name 'HAProxyServer'```

1 Answer 1


This means that, the module "HAProxyServer" is not present in your python module. You will have to install it using the below command:

pip install haproxy-stats

Please refer the official documentation:


  • ERROR:haproxystats:Error fetching stats from x.x.x.x:5222/;csv;norefresh: ('Connection aborted.', BadStatusLine("<?xml version='1.0'?><stream:stream xmlns='jabber:client' xmlns:stream='etherx.jabber.org/streams' id='2954829834' from='xxxxx' version='1.0' xml:lang=''><stream:error><xml-not-well-formed xmlns='urn:ietf:params:xml:ns:xmpp-streams'></xml-not-well-formed></stream:error></stream:stream>",))
    – Deepu
    Nov 12, 2019 at 9:06
  • i am using the code from github.com/bcicen/haproxy-stats
    – Deepu
    Nov 12, 2019 at 9:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .