HAProxy can generate alerts through syslog or emails to notify the administrator of HAProxy events.

Events are generated based on syslog levels from debug to emergency.

Alerts are sent when:

  • An un-paused server is marked as down and <level> is 'alert' or lower

  • A paused server is marked as down and <level> is 'notice' or lower

  • A server is marked as up or enters the drain state and <level> is 'notice' or lower

  • The service option log-health-checks is enabled with <level> as 'info' or lower, and a health check status update occurs

Using emails for alerts

To use emails for alerts, you first configure a mailers section where you define some message transfer agents (MTA) servers.

Then in the back end section, you define options for the emails to send out. Emails are sent using the SMTP protocol.

Create the mailers section

To create a new mailers section, add the following line:

mailers <mailersectionname>

where <mailersectionname> is the name of your mailers section which later serves as a label.


You can define several mailers sections in a single HAProxy configuration.

To configure additional mailer servers, add the following line:

mailer <mailername> <ip>:<port>

with the following parameters:


mail server name


mail server IP address


TCP port where the SMTP service runs on the server

Example of a mailers section configuration

mailers mta
mailer smtp1
mailer smtp2

Configure options for emails

You can configure the following sections to use emails for alerts: defaults, frontend, backend, or listen as follows:

email-alert from <emailaddr>

declares the email sender address, also known as FROM for use in both the envelopes and headers.

email-alert level <level>

declares the maximum log level of messages for which email alerts will go out; <level> can be any of these syslog levels: emerg, alert, crit, err, warning, notice, info, debug.

email-alert mailers <mailersectionname>

the mailers section to use to send emails

email-alert myhostname <hostname>

hostname address to use when communicating with mailers; by default, it is the system hostname.

email-alert to <emailaddr>

declares the recipient address for both the envelope and the header.

Send an email when a server is DOWN

mailers mta
mailer smtp1
mailer smtp2
backend b_myapp
email-alert mailers mta
email-alert level alert
email-alert from haproxy@dmydomain.com
email-alert to ops@mydomain.com