Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.

If a page opens when you type its address into a browser but Cypress reports “page not found,” do not assume Cypress is broken. The failure means Cypress requested a particular URL and received a different response—often a redirect, an unauthenticated response, or a server 404 for a client-side route. Capture the exact request URL, status, and redirect chain first; then follow the diagnostic branch that matches what the server actually returned.

Start with the request Cypress really made

Begin by recording the complete URL generated by cy.visit(). Compare it character by character with the address that works manually. Include the scheme, host, port, path, query string, hash, capitalization, and trailing slash.

describe('route diagnostic', () => {
  it('visits the intended URL', () => {
    cy.visit('/inventory.html');
  });
});

Then inspect the Cypress runner’s command log and browser developer tools. Write down:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • the configured baseUrl;
  • the relative or absolute value passed to cy.visit();
  • the final URL shown after redirects;
  • the first response status for the requested path; and
  • whether the response body is your application, a login page, or an error document.

A small URL difference can select a different server rule. For example, /inventory.html and /inventory.html/ are not interchangeable on every server. A relative path is also resolved against baseUrl, so an incorrect host, port, or base-path setting can send Cypress to another application entirely.

Verify baseUrl and path resolution

// cypress.config.js
const { defineConfig } = require('cypress');

module.exports = defineConfig({
  e2e: {
    baseUrl: 'https://www.example.test',
  },
});

With that configuration, cy.visit('/orders/42') requests https://www.example.test/orders/42. If your deployed app lives under a subdirectory, include that prefix in the base URL or in the path exactly as the server expects. Avoid “fixing” the symptom by adding random slashes until you have confirmed the URL in the network log.

Follow the response, not just the rendered page

A manual address-bar visit can look successful even when the original path returned an error and the browser was redirected somewhere else. Use the Network panel with “Preserve log” enabled, reload the page, and inspect the document request. Compare Cypress and manual requests for status code, Location header, cookies, and response body.

What you observe Likely branch Next action
Requested path differs from the manual URL Base URL or path construction Correct baseUrl, path, port, slash, or encoding.
3xx response, then application root or another page Redirect, canonicalization, or access gate Inspect every hop and test the original URL directly.
401/403 or login HTML Missing authentication or permissions Create the required session before visiting the protected route.
404 for a history-mode route Missing server fallback Serve the SPA entry document for unknown application paths.
Intermittent failure only on localhost and old versions Environment-specific proxy behavior Reproduce with current Cypress, browser, and proxy settings before trying a workaround.

Do not infer a cause from the phrase “page not found” alone. The same visible message can be produced by your web server, an authentication gateway, a reverse proxy, or the application itself.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Branch 1: the URL, slash, or host is different

Compare values literally

Print or log the value used by your test and compare it with the address that succeeds manually. Check for:

  • http versus https;
  • the expected hostname and port;
  • a deployment prefix such as /app;
  • trailing slashes and file extensions;
  • URL-encoded characters and query parameters; and
  • environment-variable expansion that produces an empty or stale value.

Use one canonical form in tests. If your server redirects a non-canonical form, assert the destination deliberately rather than hiding the redirect.

Check the configured environment

When running with a different Cypress configuration or CI environment, confirm that the selected baseUrl points to the same deployment you tested manually. A locally open tab may be using one port while Cypress is targeting another. Start the server first, wait until it is listening, and then launch Cypress against that exact origin.

Branch 2: a redirect or protected route is involved

Inspect the redirect chain

In the Network panel, open the document request and follow each 3xx response. A route that appears to “work” may redirect to the site root, a login page, or a canonical URL. Cypress can expose the original non-success response in its error even though a human notices only the final page.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Fix the underlying rule: update the test URL, correct the server redirect, or use the intended canonical route. Do not assert that a page loaded merely because the browser eventually displayed something.

Establish authentication before visiting

If the route requires a logged-in session, create that session before navigation and verify that the expected cookie or token exists. A simple pattern is to perform an API login, persist the resulting cookie, and then visit the protected page:

cy.request('POST', '/api/login', {
  username: Cypress.env('E2E_USER'),
  password: Cypress.env('E2E_PASSWORD'),
}).then((response) => {
  expect(response.status).to.eq(200);
});

cy.visit('/inventory.html');

Adapt the request to your application. Never commit real credentials, and do not assume that a session in a separate manually opened browser is available to the Cypress-controlled browser.

If Cypress lands on a login page, that is useful evidence: the route may be healthy but inaccessible without the correct state. Assert the post-login URL or a stable authenticated element so a future redirect is reported clearly.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Branch 3: history-mode single-page application routing

Client-side routers commonly use history mode, producing URLs such as /todos/42 without a physical file at that path. During in-app navigation, JavaScript receives the route and renders the view. A direct browser or Cypress request still reaches the web server first. If the server looks only for a file named todos/42, it can return 404 before the client router starts.

Configure an entry-point fallback

Configure the production server or hosting platform to return the SPA’s index.html for requests that do not match real static assets. Keep genuine asset 404s intact, then let the client router resolve the application path.

The exact rule depends on your server (for example, a reverse proxy, static host, or Node server), so verify it in that server’s documentation. The important behavior is:

  1. A request for an existing JavaScript, CSS, image, or other asset returns that asset.
  2. A request for an application route such as /todos/42 returns the app entry document.
  3. The client router reads /todos/42 and renders the correct view.

After deploying the fallback, test the route in a fresh tab by entering its deep link directly. Then run the same URL with cy.visit(). If direct loading still returns 404, the fallback is absent, scoped to the wrong host, or overridden by a proxy rule.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Check the router’s base path

If the application is hosted below the domain root, configure the router and server for the same base path. A mismatch can make navigation inside the app appear correct while a direct deep link requests the wrong location. Treat the application base URI as part of URL construction, not as a Cypress-only setting.

Branch 4: localhost, browser, and proxy differences

An older Cypress issue described intermittent 404 behavior while visiting separate localhost ports with Cypress 3.0.1 on Windows 10 and Chrome. A later comment attributed a similar symptom to Chrome bypassing Cypress’s proxy for loopback addresses and mentioned a --proxy-bypass-list=<-loopback> launch argument. This is historical, version-specific evidence—not a current universal fix.

Before changing browser flags:

  • record Cypress and browser versions;
  • record operating system and every localhost port;
  • reproduce with a minimal test and a single document request;
  • compare the request path when using localhost versus 127.0.0.1; and
  • check whether a corporate proxy, VPN, service worker, or hosts-file entry changes routing.

Upgrade or reproduce with supported current versions first. Apply a proxy flag only when your controlled reproduction demonstrates that the browser is bypassing the Cypress proxy, and document the flag in the test runner configuration so other environments do not silently diverge.

A repeatable diagnostic workflow

  1. Minimize the test. Use one cy.visit() against the failing URL and remove unrelated commands.
  2. Capture the exact request. Record resolved URL, method, status, redirects, and response body.
  3. Reproduce outside Cypress. Request that exact URL in a clean browser session or with an HTTP client, preserving the same host, port, and path.
  4. Classify the response. Decide whether it is a URL mismatch, redirect, authentication response, SPA fallback failure, or environment-specific proxy problem.
  5. Fix the owning layer. Change test configuration for a wrong URL, session setup for authentication, server routing for history mode, or environment configuration for proxy issues.
  6. Assert the result. Check a stable page element and, where useful, the URL so a future redirect or login page fails with a meaningful message.
  7. Retest in CI. Local success does not prove that CI uses the same host, deployment, credentials, browser, or proxy.

Common errors and targeted fixes

Symptom Cause to verify Fix
Only a trailing-slash variant fails Server treats slash and non-slash paths differently Use the canonical URL or configure a deliberate redirect.
Cypress ends at the home page Original path redirects or is rewritten Inspect Location headers and correct the route or access rule.
Manual tab is logged in; Cypress is not Separate browser profile and cookies Authenticate in the Cypress session before cy.visit().
Internal links work, direct deep links fail History-mode fallback missing Return index.html for unknown application routes.
Failure is intermittent on old localhost setup Proxy bypass or port-specific environment issue Capture traffic, update versions, and reproduce before using flags.
CI fails while local runs pass Different baseUrl, deployment, DNS, credentials, or proxy Print resolved configuration and compare network traces from both environments.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Performance and reliability considerations

Keep the first diagnostic run focused on one document request; video, screenshots, and unrelated retries can obscure the network evidence. Once the route is fixed, avoid excessive arbitrary waits. Wait for a meaningful application signal (for example, a stable element or API completion) so the test reflects readiness rather than a guessed delay.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use a deterministic test deployment when possible. A changing reverse-proxy rule, expiring login session, or dynamically assigned port can recreate a “page not found” symptom without any Cypress code change. Record the URL and response status in CI artifacts so a future failure can be classified without rerunning locally.

Or skip the browser setup

If your goal is a clean image or PDF of a URL rather than an end-to-end browser assertion, ScreenshotNeo provides a single screenshot request. It accepts consent banners before capture and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each step can be disabled. Bot checks, CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and the response identifies the page verdict and billing result in headers.

Use the API documentation at https://screenshotneo.com/docs/ for all options. A cURL request:

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

Python:

import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
open("shot.webp", "wb").write(r.content)

Node.js:

const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);

ScreenshotNeo also offers an MCP server with take_screenshot, get_page_info, and capture_pdf tools for Claude, Cursor, and other MCP clients. Every plan includes its capture options; the Free plan allows 1,000 screenshots per month without a card, and paid plans start at $5 for 3,000 shots. Sign up for the free plan.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Frequently Asked Questions

Should I add a retry to hide the Cypress 404?

No. A retry can mask a redirect, missing authentication, or a server fallback defect. Capture the request and fix the layer returning the wrong response.

Can I use an absolute URL in every `cy.visit()` call?

You can, but it does not repair authentication, server routing, or proxy problems. Keep URLs centralized so environments can change hosts safely.

Why does clicking a link work when opening its URL directly fails?

Client-side navigation may resolve the route without a full server request. Direct loading requires the server or hosting layer to provide the SPA entry-point fallback.

Is the loopback proxy launch flag a standard Cypress solution?

No. It came from an older, specific localhost report. Reproduce the behavior with current Cypress and browser versions before considering it.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.