high

CypressError: cy.request() failed

cy.request() failed because the server returned an error, the connection was refused, or the request timed out.

Common Causes

  1. 1API server is down or unreachable
  2. 2Authentication token is missing or expired
  3. 3Request body is malformed
  4. 4CORS configuration blocks the request
  5. 5SSL certificate issues

How to Fix

Allow failures with failOnStatusCode

cy.request({
  url: '/api/data',
  failOnStatusCode: false,
}).then((response) => {
  expect(response.status).to.eq(404);
});

When testing error cases, disable automatic failure on non-2xx status codes.

Add authentication headers

cy.request({
  url: '/api/data',
  headers: {
    Authorization: `Bearer ${Cypress.env('API_TOKEN')}`,
  },
});

Include auth headers for protected endpoints. Store tokens in Cypress environment variables.

How ObserveOne Helps

ObserveOne monitors your API endpoints 24/7 and catches errors before they impact your test suite.

Start Monitoring Free

Related Errors