Query: “cypress could not verify that this server is running”
This error message usually indicates that Cypress, a JavaScript end-to-end testing framework, is unable to establish a connection with the server it is supposed to interact with during the test. There can be multiple reasons for this error to occur.
Here are some possible reasons and their solutions:
-
Server not started or running on a different port: Make sure the server you are trying to test is running and accessible. Additionally, ensure that the server is running on the expected port. Cypress defaults to using port 8080, but you can modify it if needed.
cy.visit('http://localhost:8080')
-
Server startup time or network delay: Sometimes, the server may take longer than expected to start, especially in complex applications. In such cases, you can increase the timeout value using the
defaultCommandTimeout
configuration option in thecypress.json
file:{ "defaultCommandTimeout": 10000 }
- Firewall or proxy settings: If you are running Cypress from behind a firewall or a proxy, ensure that the necessary firewall rules or proxy configurations are in place to allow Cypress to reach the server.
-
SSL certificate issues: In some cases, if the server uses a self-signed SSL certificate, Cypress might reject the connection by default. You can disable SSL verification by adding the following lines of code to your test:
Cypress.on('uncaught:exception', (err, runnable) => { if (err.message.includes('ERR_CERT_INVALID')) { // Ignore SSL certificate errors return false; } })
-
Incorrect base URL: Verify that the base URL used by Cypress to visit the server is correct. You can set the base URL in the
cypress.json
configuration file or directly in your test code usingcy.visit()
:cy.visit('https://example.com')
By examining these potential issues and implementing the corresponding solutions, you should be able to resolve the “cypress could not verify that this server is running” error and establish the connection between Cypress and the server successfully.
Read more interesting post
- Expected to find project root in current working directory.
- * the terminal process failed to launch (exit code: -1). * terminal will be reused by tasks, press any key to close it.
- Cannot find module ‘@angular/core’ or its corresponding type declarations.
- Cannot read properties of null (reading ‘usestate’)
- Cypress contains exact match