Fixing ERR_CERT_AUTHORITY_INVALID in Playwright
When you open an HTTPS page with a self-signed certificate in Playwright, page.goto() fails with net::ERR_CERT_AUTHORITY_INVALID. Setting ignoreHTTPSErrors: true in the use section of the config file makes this error go away. You see it when you run E2E tests against a local dev server or a staging environment that uses HTTPS.
I caused the error in a test environment and confirmed that ignoreHTTPSErrors removes it. I also checked a way to keep certificate verification on (trusting a self-made CA), and a different form of the error that shows up in API tests and in webServer startup waits.
The test environment was Ubuntu 24.04, Node.js 22.23.5, @playwright/test 1.63.0 (Chromium 157.0.8103.78, headless), TypeScript 5.9.3, and OpenSSL 3.0.13. I created the certificates with OpenSSL and ran the HTTPS servers with Node.js's https module on ports 3443 and 3444 of localhost. I did not test Firefox or WebKit, macOS or Windows, or headed browsers.
Reproducing the error
First, I created a self-signed certificate with OpenSSL. The issuer is the same as the subject, so the certificate is its own issuer.
openssl req -x509 -newkey rsa:2048 -nodes -keyout self.key -out self.crt -days 30 \
-subj "/CN=localhost" -addext "subjectAltName=DNS:localhost"
$ openssl x509 -in self.crt -noout -subject -issuer -ext subjectAltName
subject=CN = localhost
issuer=CN = localhost
X509v3 Subject Alternative Name:
DNS:localhost
With this certificate, I ran an HTTPS server on port 3443 that returns a page with a single heading. /api returns JSON.
// server.mjs (excerpt)
https
.createServer({ key: readFileSync(s.key), cert: readFileSync(s.cert) }, (req, res) => {
if (req.url === '/api') {
res.writeHead(200, { 'Content-Type': 'application/json' });
res.end(JSON.stringify({ ok: true, port: s.port }));
return;
}
res.writeHead(200, { 'Content-Type': 'text/html; charset=utf-8' });
res.end(page(s.label));
})
.listen(s.port);
There are two tests: one opens the page and checks the heading, and the other calls the API with request.
// tests/default/page.spec.ts
import { test, expect } from '@playwright/test';
test('自己署名の証明書のページを開く', async ({ page }) => {
await page.goto('https://localhost:3443/');
await expect(page.getByRole('heading')).toHaveText('自己署名の証明書のページ');
});
// tests/default/api.spec.ts
import { test, expect } from '@playwright/test';
test('自己署名の証明書の API を呼ぶ', async ({ request }) => {
const res = await request.get('https://localhost:3443/api');
expect(res.status()).toBe(200);
});
Without any configuration, both tests failed. The output below has the blank lines removed, and I replaced the working directory path with /path/to/app.
$ npx playwright test --project=default
Running 2 tests using 1 worker
✘ 1 [default] › tests/default/api.spec.ts:3:1 › 自己署名の証明書の API を呼ぶ (49ms)
✘ 2 [default] › tests/default/page.spec.ts:3:1 › 自己署名の証明書のページを開く (1.1s)
1) [default] › tests/default/api.spec.ts:3:1 › 自己署名の証明書の API を呼ぶ ─────────────────────────────────
Error: apiRequestContext.get: self-signed certificate
Call log:
- → GET https://localhost:3443/api
- user-agent: Playwright/1.63.0 (x64; ubuntu 24.04) node/22.23
- accept: */*
- accept-encoding: gzip,deflate,br
2 |
3 | test('自己署名の証明書の API を呼ぶ', async ({ request }) => {
> 4 | const res = await request.get('https://localhost:3443/api');
| ^
5 | expect(res.status()).toBe(200);
6 | });
7 |
at /path/to/app/tests/default/api.spec.ts:4:29
Error Context: test-results/api-自己署名の証明書の-API-を呼ぶ-default/error-context.md
2) [default] › tests/default/page.spec.ts:3:1 › 自己署名の証明書のページを開く ──────────────────────────────────
Error: page.goto: net::ERR_CERT_AUTHORITY_INVALID at https://localhost:3443/
Call log:
- navigating to "https://localhost:3443/", waiting until "load"
2 |
3 | test('自己署名の証明書のページを開く', async ({ page }) => {
> 4 | await page.goto('https://localhost:3443/');
| ^
5 | await expect(page.getByRole('heading')).toHaveText('自己署名の証明書のページ');
6 | });
7 |
at /path/to/app/tests/default/page.spec.ts:4:14
Error Context: test-results/page-自己署名の証明書のページを開く-default/error-context.md
2 failed
[default] › tests/default/api.spec.ts:3:1 › 自己署名の証明書の API を呼ぶ ──────────────────────────────────
[default] › tests/default/page.spec.ts:3:1 › 自己署名の証明書のページを開く ───────────────────────────────────
The browser test fails with page.goto: net::ERR_CERT_AUTHORITY_INVALID at https://localhost:3443/, while the API test fails with apiRequestContext.get: self-signed certificate. The same certificate gives different messages because Chromium checks it for the page, and Node.js checks it for request. Each has its own fixes.

Fixing it with ignoreHTTPSErrors: true
The ignoreHTTPSErrors test option controls whether HTTPS errors are ignored when sending requests. It defaults to false. In my test, I split the tests into projects and set true only on the ignore project. To apply it to every test, put it in use outside of projects.
// playwright.config.ts
import { defineConfig } from '@playwright/test';
export default defineConfig({
reporter: 'list',
workers: 1,
webServer: {
command: 'node server.mjs',
url: 'https://localhost:3443',
ignoreHTTPSErrors: true,
},
use: { browserName: 'chromium' },
projects: [
{ name: 'default', testDir: './tests/default' },
{ name: 'ignore', testDir: './tests/ignore', use: { ignoreHTTPSErrors: true } },
{ name: 'ca', testDir: './tests/ca' },
],
});
I placed the same two tests in tests/ignore. Both passed when I ran them.
$ npx playwright test --project=ignore
Running 2 tests using 1 worker
✓ 1 [ignore] › tests/ignore/api.spec.ts:3:1 › 自己署名の証明書の API を呼ぶ (34ms)
✓ 2 [ignore] › tests/ignore/page.spec.ts:3:1 › 自己署名の証明書のページを開く (130ms)
2 passed (797ms)
In use, ignoreHTTPSErrors worked both for pages opened in the browser and for APIs called with request.
As the official documentation says, ignoreHTTPSErrors: true ignores HTTPS errors. This turns off certificate checks, so do not use it for tests against production sites. Only set it on a project that targets a test server using a self-signed certificate.
webServer startup also needs ignoreHTTPSErrors
If you start a server with webServer in the config file and give it an HTTPS address as url, you also need ignoreHTTPSErrors: true inside webServer. That is why the config file above sets it there. According to the official webServer documentation, ignoreHTTPSErrors in webServer controls whether HTTPS errors are ignored when checking url. It defaults to false.
I made a separate config file with ignoreHTTPSErrors: true in use but without it in webServer, and ran it with a 10-second timeout.
// pw-webserver-noignore.config.ts (excerpt)
webServer: {
command: 'node server.mjs',
url: 'https://localhost:3443',
timeout: 10_000,
},
use: { browserName: 'chromium', ignoreHTTPSErrors: true },
$ npx playwright test -c pw-webserver-noignore.config.ts
[WebServer] Self-signed certificate detected. Try adding ignoreHTTPSErrors: true to config.webServer.[WebServer] Self-signed certificate detected. Try adding ignoreHTTPSErrors: true to config.webServer.
(同じメッセージが続くため、途中を省略。全部で 12 回出た)
Error: Timed out waiting 10000ms from config.webServer.
Playwright received the self-signed certificate from the server, but the check on url kept failing because of the certificate error, and it gave up after 10 seconds. No tests ran. ignoreHTTPSErrors in use does not apply to the webServer check, so you must set it in both places.
Keeping certificate checks on by trusting a self-made CA
You can also avoid ignoreHTTPSErrors and trust only the certificate you use for tests. Create your own CA (the certificate authority that signs certificates), sign the server certificate with it, and make the browser and Node.js trust that CA.
Creating the CA and server certificate
# Create the CA
openssl req -x509 -newkey rsa:2048 -nodes -keyout ca.key -out ca.crt -days 30 \
-subj "/CN=Test Local CA" \
-addext "basicConstraints=critical,CA:TRUE" -addext "keyUsage=critical,keyCertSign,cRLSign"
# Create the server key and signing request, then sign it with the CA
openssl req -newkey rsa:2048 -nodes -keyout server.key -out server.csr -subj "/CN=localhost"
printf "subjectAltName=DNS:localhost\nextendedKeyUsage=serverAuth\n" > server.ext
openssl x509 -req -in server.csr -CA ca.crt -CAkey ca.key -CAcreateserial -out server.crt -days 30 -extfile server.ext
$ openssl x509 -in server.crt -noout -subject -issuer -ext subjectAltName
subject=CN = localhost
issuer=CN = Test Local CA
X509v3 Subject Alternative Name:
DNS:localhost
I ran a server with this certificate on port 3444. In the ca project, which does not set ignoreHTTPSErrors, both the page test and the API test failed when they opened the port 3444 server. The page test failed with the same net::ERR_CERT_AUTHORITY_INVALID. The API test failed with unable to verify the first certificate.
$ npx playwright test --project=ca
(一部を抜粋)
Error: apiRequestContext.get: unable to verify the first certificate
Error: page.goto: net::ERR_CERT_AUTHORITY_INVALID at https://localhost:3444/
2 failed
Trusting the CA in the browser's NSS database
According to the official Chromium documentation on certificate management on Linux, Chromium on Linux manages certificates in a shared NSS database. From Chromium 146 the default location is $HOME/.local/share/pki/nssdb. If the older $HOME/.pki/nssdb already exists, that one is used. To register a certificate, use certutil (in Ubuntu, the libnss3-tools package), and register the CA with trust flags C,,.
In my test, I changed HOME to a new empty directory, created only the .local/share/pki/nssdb directory, and ran the test above. After the test, Chromium had created database files there, so I registered the CA in that database. The paths below use $HOME in place of the actual path.
$ ls $HOME/.local/share/pki/nssdb
cert9.db
key4.db
pkcs11.txt
$ certutil -d sql:$HOME/.local/share/pki/nssdb -A -t "C,," -n "Test Local CA" -i certs/ca.crt
$ certutil -d sql:$HOME/.local/share/pki/nssdb -L
Certificate Nickname Trust Attributes
SSL,S/MIME,JAR/XPI
Test Local CA C,,
When I ran the same test again, the page test passed. The API test still failed with the same error.
$ npx playwright test --project=ca
(一部を抜粋)
✘ 1 [ca] › tests/ca/api.spec.ts:3:1 › 自作の CA で署名した証明書の API を呼ぶ (49ms)
✓ 2 [ca] › tests/ca/page.spec.ts:3:1 › 自作の CA で署名した証明書のページを開く (145ms)
Error: apiRequestContext.get: unable to verify the first certificate
1 failed
1 passed (1.4s)
Trusting the CA for request with NODE_EXTRA_CA_CERTS
Node.js does the certificate check for request, so you pass the CA file through the environment variable NODE_EXTRA_CA_CERTS. According to the official documentation, this variable adds the certificates in the specified file to the CAs Node.js already trusts. It is read only when the Node.js process starts. Setting it with process.env inside the test code does not work, so pass it when you run the command.
$ env NODE_EXTRA_CA_CERTS=certs/ca.crt npx playwright test --project=ca
Running 2 tests using 1 worker
✓ 1 [ca] › tests/ca/api.spec.ts:3:1 › 自作の CA で署名した証明書の API を呼ぶ (58ms)
✓ 2 [ca] › tests/ca/page.spec.ts:3:1 › 自作の CA で署名した証明書のページを開く (127ms)
2 passed (1.0s)
Both tests passed without ignoreHTTPSErrors.
Trusting the self-signed certificate directly, without a CA
If you only need pages opened in the browser, you can skip the CA and register the self-signed certificate itself in the NSS database. According to the Chromium documentation, you register a self-signed server certificate with trust flags P,,.
In my test, I changed HOME to another new empty directory. There was no database yet, so I created one with an empty password using -N and then registered the certificate.
$ certutil -d sql:$HOME/.local/share/pki/nssdb -N --empty-password
$ certutil -d sql:$HOME/.local/share/pki/nssdb -A -t "P,," -n "self localhost" -i certs/self.crt
$ npx playwright test --project=default tests/default/page.spec.ts
Running 1 test using 1 worker
✓ 1 [default] › tests/default/page.spec.ts:3:1 › 自己署名の証明書のページを開く (126ms)
1 passed (844ms)
The test that first failed with net::ERR_CERT_AUTHORITY_INVALID passed without ignoreHTTPSErrors.





