Troubleshooting

HAProxy: No Private Key found in PEM file / unable to load SSL private key

HAProxy found a certificate but no key in the file crt names. Tested on HAProxy 3.2.26: each wording since 2.0, the cat recipe, directory traps and the openssl check.

· 15 min read · How we verify this

Key points

  • The error means HAProxy read the file that crt points at, found a certificate, and found no private key in it or beside it. Since 2.3 the line names the file it looked in last, such as No Private Key found in '/etc/haproxy/certs/site.pem.key'. The .key on the end is HAProxy's guess at a separate key file, not a file you named.
  • The fix for a Let's Encrypt certificate is one command: cat fullchain.pem privkey.pem > /etc/haproxy/certs/example.com.pem, then point crt at that file. Run it again after each renewal, because the copy does not update itself.
  • The key can sit anywhere in the file: HAProxy reads the key first, then goes back to the top for the certificates. What matters is the certificate order. Your site's certificate must come before the chain, or you get inconsistencies between private key and certificate loaded.
  • crt pointing at a directory loads every file in it as a certificate, except names ending in .key, .issuer, .ocsp or .sctl and names starting with a dot. Point it at a Let's Encrypt live/ folder, or leave a privkey.pem, chain.pem, README or .bak file in it, and HAProxy refuses to start.
  • The wording depends on the version. 2.0 said unable to load SSL private key from PEM file, 2.1 said unable to load private key from file, 2.2 alone said No Private Key found in '<file>' or '<file>.key', and 2.3 to 3.3 name the .key path.

HAProxy prints No Private Key found in '<file>.key' when the file named by crt holds a certificate but no private key, and no separate key file sits next to it. HAProxy refuses to start. The older wording, unable to load SSL private key from PEM file, means the same thing in HAProxy 2.0. The fix is almost always to put the key into the same file as the certificate:

bash
cat /etc/letsencrypt/live/example.com/fullchain.pem \
    /etc/letsencrypt/live/example.com/privkey.pem \
    > /etc/haproxy/certs/example.com.pem

Then point the bind line at the new file, with crt /etc/haproxy/certs/example.com.pem. The table maps each line HAProxy 3.2.26 printed in testing on 16 November 2026 to its cause. Each row is explained further down.

What the error saysWhat HAProxy foundFix
No Private Key found in '/etc/haproxy/certs/site.pem.key'.A certificate but no key in site.pem, and no site.pem.key beside itAdd the key to the file, or save it as site.pem.key
No Private Key found in '/etc/haproxy/certs/site.pem'.The same, with ssl-load-extra-files set so it skips .key filesAdd the key to the file
No Private Key found in '/etc/haproxy/certs/site.crt.key'.A site.crt and a site.key, without ssl-load-extra-del-extAdd ssl-load-extra-del-ext to global, or rename the key
No Private Key found in '.../cert.pem.key' or '.../chain.pem.key'crt names a directory that holds Let's Encrypt's separate filesBuild one combined file per site in a clean directory
unable to load certificate from file '.../privkey.pem': no start line.A key file, or any other non-certificate file, in a crt directoryMove it out, or name it <cert>.key
inconsistencies between private key and certificate loaded '<file>'.A key, but not the key for the first certificate in the filePut your site's certificate first, or use the right key
Enter PEM pass phrase:, then No Private Key foundAn encrypted keyRemove the passphrase on 3.2, or use ssl-passphrase-cmd on 3.3
cannot open the file '<file>'.A file HAProxy is not allowed to readFix the owner or the mode

What the error means: PEM, certificate, key and chain#

A PEM file is a text file that holds one or more blocks of base64 text. Each block sits between a -----BEGIN ...----- line and an -----END ...----- line, and the word after BEGIN says what the block is.

Two kinds of block matter here. A certificate (BEGIN CERTIFICATE) is public. It names your site and carries your public key, signed by a certificate authority. A private key (BEGIN PRIVATE KEY, or BEGIN RSA PRIVATE KEY or BEGIN EC PRIVATE KEY in older formats) is secret. It is the other half of that public key. A server needs both to finish a TLS handshake, because it proves it owns the certificate by using the key.

The chain is the list of intermediate certificates between your certificate and a root that browsers trust. Your own certificate is called the leaf, since it sits at the end of the chain.

The crt keyword on a bind line tells HAProxy where to find all of this. The 3.2 manual says it "designates a PEM file containing both the required certificates and any associated private keys", and it shows the same recipe as above: "cat cert.pem key.pem > combined.pem". That is the core difference from nginx and Apache. Both of those take the certificate and the key as two settings. HAProxy takes one file, and if the key is not in it, it goes looking.

Why the line names a .key file you never created#

The manual explains the search: "If the file does not contain a private key, HAProxy will try to load the key at the same path suffixed by a '.key'." So for crt /etc/haproxy/certs/site.pem, HAProxy checks site.pem first, then site.pem.key.

In HAProxy 2.3 and later, when both come up empty, the error names the last place it looked. That is why the message points at site.pem.key, a file that may never have existed. The real problem is that site.pem has no key. Here is the full line from HAProxy 3.2.26, for a file holding only fullchain.pem:

text
[ALERT]    (1) : config : parsing [/lab/haproxy.cfg:9] : 'bind :8443' in section 'frontend' : No Private Key found in '/lab/site.pem.key'.

There are two ways to fix it, and both were tested. Put the key into site.pem, or save the key as site.pem.key beside it. Both started cleanly.

The search for .key is controlled by ssl-load-extra-files in the global section. Its default is all, which includes key. If you set it to a list without key, or to none, HAProxy does not look for the extra file, and the line names the PEM file itself:

text
No Private Key found in '/lab/site.pem'.

The message in each HAProxy version#

People search for every one of these wordings, and old answers quote old ones. The table comes from the HAProxy source at each release tag. Each string is for a crt on a bind line.

HAProxy versionText when the key is missingSource file
2.0unable to load SSL private key from PEM file '<file>'.src/ssl_sock.c
2.1unable to load private key from file '<file>'.src/ssl_sock.c
2.2No Private Key found in '<file>' or '<file>.key'.src/ssl_ckch.c
2.3 to 3.3No Private Key found in '<file>.key'.src/ssl_ckch.c
2.6 to 3.3, with key left out of ssl-load-extra-filesNo Private Key found in '<file>'.src/ssl_ckch.c

The "or <file>.key" wording that most forum threads quote lived in 2.2 only. From 2.3, the code appends .key to the path first and prints only that.

The old wording also lived on in one place. For a client certificate on a server line (server ... ssl crt client.pem, the HAProxy side of mutual TLS), HAProxy kept printing unable to load SSL private key from PEM file through 2.3. The 2.4 source no longer has it. On 3.2.26 a server line with no key gave the current form:

text
[ALERT]    (1) : [/lab/haproxy.cfg:10] : 'server be/s1' : No Private Key found in '/lab/certs/client.pem.key'.

A crt-list gives the same message, plus a second line under it:

text
'crt-list' : error processing line 1 in file '/lab/list.txt' : No Private Key found in '/lab/certs/site.pem.key'.
unable to load SSL private key into SSL Context '/lab/certs/site.pem': passed a null parameter.

The second line follows from the first. Fix the missing key and both go away.

How the cases were tested#

Everything below was run on 16 November 2026 unless it is quoted from the manual or the source. HAProxy 3.2.26 ran from the official haproxy:3.2-alpine image, which runs as user haproxy (uid 99). Each case was checked with haproxy -c -f haproxy.cfg. The certificates came from a test root, one intermediate and a leaf for www.example.test, copied into the four files that Let's Encrypt's certbot writes: cert.pem, chain.pem, fullchain.pem and privkey.pem. For the cases that started, a live HAProxy was checked with openssl s_client and curl.

Build the combined file: order and recipe#

The order inside the file is less strict than most answers say. In the source, the loader reads the private key first. Then it seeks back to the top of the file and reads the first certificate as yours. Every certificate after that is treated as the chain.

So the key can go anywhere. Three files started cleanly in testing:

  • key last: fullchain.pem, then privkey.pem;
  • key first: privkey.pem, then fullchain.pem;
  • key in the middle: cert.pem, privkey.pem, then chain.pem.

The live HAProxy served the right chain for the key-in-the-middle file: the leaf for www.example.test, then the intermediate. openssl s_client reported Verify return code: 0 (ok).

The certificate order is the strict part. Your site's certificate must be the first certificate in the file. A file built as chain.pem, cert.pem, privkey.pem failed:

text
'bind :8443' in section 'frontend' : inconsistencies between private key and certificate loaded '/lab/site.pem'.

HAProxy took the intermediate as the site's certificate, and the key did not match it. A key that belongs to another certificate gives the very same line. In the source, the check is OpenSSL's X509_check_private_key(), which compares the key with the first certificate's public key.

Let's Encrypt's fullchain.pem already has the leaf first, so fullchain.pem then privkey.pem is the order to use:

bash
mkdir -p /etc/haproxy/certs
cat /etc/letsencrypt/live/example.com/fullchain.pem \
    /etc/letsencrypt/live/example.com/privkey.pem \
    > /etc/haproxy/certs/example.com.pem
chmod 600 /etc/haproxy/certs/example.com.pem
haproxy -c -f /etc/haproxy/haproxy.cfg

Two notes on that recipe. First, the combined file is a copy. When certbot renews the certificate, the copy keeps the old one until you run the cat again and reload HAProxy, so add it to your renewal step. Second, the file holds the key, so keep the mode tight. But the account that starts HAProxy has to read it. In the test, a file owned by root with mode 600 gave:

text
'bind :8443' in section 'frontend' : cannot open the file '/lab/certs/site.pem'.

Use cert.pem instead of fullchain.pem and HAProxy still starts, because the key matches. But it then sends no intermediate. In the test, openssl s_client against that setup reported Verify return code: 21 (unable to verify the first certificate). Browsers that do not already hold the intermediate fail the same way, so use fullchain.pem.

Check that the key matches the certificate#

Before you reload, compare the public key inside the certificate with the public key made from the private key. If the two hashes match, the pair belongs together:

bash
openssl x509 -in /etc/haproxy/certs/example.com.pem -noout -pubkey | openssl sha256
openssl pkey -in /etc/haproxy/certs/example.com.pem -pubout | openssl sha256

Both commands read a combined file the same way HAProxy does. openssl x509 takes the first certificate in the file, and openssl pkey takes the first key. That makes the check useful for order mistakes too. On the file with the chain first, the two hashes differed, just as HAProxy's check failed. On the correct files, they matched. These commands were run with OpenSSL 1.1.1f. They also work on separate files: point the first at the certificate and the second at the key.

To see which certificate HAProxy will treat as yours, print the first one's subject:

bash
openssl x509 -in /etc/haproxy/certs/example.com.pem -noout -subject

If it shows your CA's intermediate rather than your site's name, the order is wrong. On the bad test file it printed subject=CN = Lab Intermediate.

A directory in crt: every file is a certificate#

Many configs point crt at a folder, so one bind line serves many sites. The manual's rule is plain: "all files found in that directory will be loaded in alphabetic order unless their name ends with '.key', '.issuer', '.ocsp' or '.sctl'". It adds that "files starting with a dot are also ignored". Every other file is read as a certificate file in its own right, and each one needs its own key.

That breaks four common setups. Each was tested.

Pointing at a Let's Encrypt live folder. With crt /etc/letsencrypt/live/example.com/, HAProxy loads cert.pem first, as it comes first in alphabetic order. That file has no key:

text
No Private Key found in '/lab/certs/cert.pem.key'.

A stray privkey.pem beside a good combined file. HAProxy tries to load it as a certificate, finds a key but no certificate, and stops:

text
unable to load certificate from file '/lab/certs/privkey.pem': no start line.

A stray chain.pem. The intermediate loads as a certificate, then has no key:

text
No Private Key found in '/lab/certs/chain.pem.key'.

Any other file. A README gave no start line, like privkey.pem. A backup named site.pem.bak was loaded as one more certificate and asked for site.pem.bak.key. A file named .hidden.pem was skipped.

The rule for a directory, then: one combined file per site, and nothing else. If you keep keys apart, name each one after its certificate plus .key. A directory holding site.pem (the full chain) and site.pem.key started cleanly, because .key files are skipped as certificates and found as keys.

The order matters in another way, too. The manual says that when a client sends no SNI, or a name that matches no certificate, "the first loaded certificate will be presented". In a directory, the first loaded is the first in alphabetic order. The site's guide to SNI routing covers why a defined default matters.

site.crt and site.key: ssl-load-extra-del-ext#

Many CAs and tools hand out example.crt and example.key. HAProxy adds .key to the whole name, so for crt site.crt it looks for site.crt.key:

text
No Private Key found in '/lab/site.crt.key'.

The global setting ssl-load-extra-del-ext changes that. The manual says that with it, "HAProxy removes the extension before adding the new one (ex: with 'foobar.crt' load 'foobar.key')". With that one line in global, the same pair started cleanly, and so did a directory holding site.crt and site.key.

It only strips .crt. The manual says "your crt file must have a '.crt' extension for this option to work". In the test, site.pem with site.key still failed with the option on, and the line still named site.pem.key. So either name the certificate .crt, or name the key after the full file name.

Keep the key in its own file: crt-store and crt-list#

If you would rather not merge files, HAProxy 3.0 and later can take the key as a separate setting in a crt-store section. The 3.2 manual says a load line's key keyword will "load a private key in PEM format". This config started cleanly on 3.2.26 with certbot's two files as they are:

haproxy
crt-store le
    crt-base /etc/letsencrypt/live/example.com
    key-base /etc/letsencrypt/live/example.com
    load crt fullchain.pem key privkey.pem alias site

frontend fe_https
    bind :443 ssl crt "@le/site"

The 3.2 manual says the same load options "are also usable in a crt-list". A crt-list line of /etc/haproxy/certs/fullchain.pem [key /etc/haproxy/certs/privkey.pem] www.example.test also started cleanly on 3.2.26. Both forms read the files where certbot writes them. So a renewal needs only a reload, with no cat step.

An encrypted key#

A key with a passphrase starts with BEGIN ENCRYPTED PRIVATE KEY. HAProxy 3.2 has no setting to supply the passphrase for a crt file. In the test, HAProxy printed Enter PEM pass phrase: twice, with no one there to type it, and then failed with No Private Key found in '/lab/site.pem.key'.

On 3.2, write out an unencrypted copy and use that:

bash
openssl pkey -in encrypted.key -out site.key

The 3.3 manual adds ssl-passphrase-cmd, a command that "will be called when an encrypted certificate is loaded during init" and prints the passphrase. It is not in the 3.2 manual.

Two things that people often suspect turned out not to matter. A key in the older BEGIN RSA PRIVATE KEY format loaded fine. So did a combined file with Windows line endings (CRLF).

Worked case: a Let's Encrypt folder in crt#

Take a new server with certbot already run for example.com. The HAProxy frontend reads:

haproxy
frontend fe_https
    bind :443 ssl crt /etc/letsencrypt/live/example.com/

Suppose haproxy -c prints No Private Key found in '/etc/letsencrypt/live/example.com/cert.pem.key'. Walk it through.

  1. The path ends in .key, and nobody created that file. So HAProxy found a certificate in cert.pem, found no key in it, and then tried the .key guess.
  2. cert.pem was never named in the config. crt names a directory, so HAProxy is loading every file in it, and cert.pem comes first in alphabetic order.
  3. Moving cert.pem away would not help. chain.pem comes next and fails the same way, and privkey.pem would fail with no start line. A folder of separate files cannot work with crt in directory mode.
  4. The fix is a new directory, /etc/haproxy/certs/, holding one file built with cat fullchain.pem privkey.pem. Change the bind line to crt /etc/haproxy/certs/.
  5. Before reloading, run the two openssl hash commands on the new file. The hashes should match. Then haproxy -c -f /etc/haproxy/haproxy.cfg should report no alert.
  6. On HAProxy 3.0 or later, there is a second way. Leave the files where they are and add a crt-store with load crt fullchain.pem key privkey.pem, as shown above.

Had the line said inconsistencies between private key and certificate loaded instead, the path would split at step 1. The key was found. The question would then be which certificate comes first in the file.

Where this answer stops applying#

The messages and results above come from HAProxy 3.2.26 with OpenSSL, on Docker on Linux. The version table comes from source at the release tags, not from running each version. Builds linked against AWS-LC or wolfSSL were not tested. Nor were multi-cert bundles (.rsa and .ecdsa suffixes), certificates added at runtime with set ssl cert, OCSP files, or ACME in crt-store. Products built on HAProxy, such as OPNsense, pfSense or the OpenShift router, write the PEM files themselves and were not tested either.

A clean start proves only that each key matches its certificate. It does not prove the chain is complete or that the certificate covers the names clients ask for. Check that with openssl s_client from outside. Where TLS ends and how traffic reaches the backend is a separate choice, set out in TLS termination, passthrough and re-encryption. TLS failures between HAProxy and its servers are a different problem. The Layer6 section of HAProxy health check failed covers ca-file and check-ssl. Why nginx fails the TLS handshake to an HTTPS upstream also sets out HAProxy's server TLS defaults. The HAProxy configuration guide shows where the bind ... ssl crt line sits in a full config.

Frequently asked questions#

What does "No Private Key found in" mean in HAProxy?#

HAProxy read the file named by crt, found a certificate, and found no private key in it. Then it looked for the same name plus .key and found nothing there either. The line names that last path. Add the key to the certificate file with cat fullchain.pem privkey.pem > site.pem.

Why does HAProxy look for a .pem.key file?#

Because ssl-load-extra-files defaults to all, which includes key. When the PEM file has no key, HAProxy tries the same path with .key added, so site.pem leads to site.pem.key. The error names that file even if it never existed.

What order should the HAProxy PEM file be in?#

Your site's certificate first, then the intermediates, and the key anywhere. HAProxy reads the key first and then rereads the file from the top for certificates. cat fullchain.pem privkey.pem gives a working order. Putting the chain before your certificate gives inconsistencies between private key and certificate loaded.

What does "unable to load SSL private key from PEM file" mean?#

It is the HAProxy 2.0 wording of the same error. The file named by crt held no private key HAProxy could read. HAProxy 2.1 said unable to load private key from file, and 2.2 and later say No Private Key found in. The fix is the same.

How do I check that a private key matches a certificate?#

Hash the public key from each side and compare. Run openssl x509 -in site.pem -noout -pubkey | openssl sha256 and openssl pkey -in site.pem -pubout | openssl sha256. Matching hashes mean the pair belongs together. On a combined file, both read the first item, as HAProxy does.

Can I point HAProxy crt at the Let's Encrypt live directory?#

No. A directory in crt loads every file in it as a certificate, so cert.pem and chain.pem fail for want of a key, and privkey.pem fails as a certificate. Build one combined file per site in a separate directory. On 3.0 and later, a crt-store can load fullchain.pem and privkey.pem as they are.

How do I use a .crt and .key pair with HAProxy?#

Add ssl-load-extra-del-ext to the global section. HAProxy then strips .crt before adding .key, so site.crt finds site.key. It works only for files ending in .crt. Without it, HAProxy looks for site.crt.key.

Primary sources#

Every normative claim on this page is checked against the specification or the vendor documentation listed here. Where behaviour is version dependent, the version is named in the text.

  1. HAProxy source, src/ssl_ckch.c, master branch (ssl_sock_load_files_into_ckch, ssl_sock_load_pem_into_ckch)
  2. HAProxy source, src/ssl_ckch.c at v3.2.0 (No Private Key found, inconsistencies between private key and certificate loaded)
  3. HAProxy source, src/ssl_ckch.c at v2.3.0 (first release naming only the .key path)
  4. HAProxy source, src/ssl_ckch.c at v2.2.0 (No Private Key found in '%s' or '%s.key')
  5. HAProxy source, src/ssl_sock.c at v2.1.0 (unable to load private key from file)
  6. HAProxy source, src/ssl_sock.c at v2.0.0 (unable to load SSL private key from PEM file)
  7. HAProxy 3.2.0 configuration manual (bind crt, crt-list, ssl-load-extra-files, ssl-load-extra-del-ext, crt-store, load options)
  8. HAProxy 3.3.0 configuration manual (ssl-passphrase-cmd)

Found something wrong, or behaviour that differs on your version? Report it with the version number and a primary source. Anything substantive is fixed in the page and logged on the corrections page. See editorial standards for how pages are researched, sourced and reviewed.

More in troubleshooting proxies#