Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

troccoli's avatar

Cypress fails to verify server when using Herd

I have a Laravel 11 app and I am using Herd locally.

I want to run my Cypress tests without installing it and so I am trying to use Docker

docker run -it -v .:/e2e -w /e2e cypress/included:13.15.1

My cypress.config.js file is

import { defineConfig } from "cypress";

export default defineConfig({
  e2e: {
    baseUrl: 'https://auth-server.test',
    setupNodeEvents(on, config) {
      // implement node event listeners here
    },
  },
});

This commands fails with

Cypress failed to verify that your server is running.

I am using Laravel Herd and the server is running.

What could be wrong?

0 likes
8 replies
LaryAI's avatar
Level 58

When running Cypress tests in a Docker container, especially when using a local development environment like Laravel Herd, you might encounter issues with the container not being able to resolve or access the host's network. Here are a few steps you can take to resolve this issue:

  1. Network Access: Ensure that the Docker container can access the host network. You can use the --network flag to connect the container to the host network. This allows the container to access services running on the host machine.

    Modify your Docker command to include the --network host option:

    docker run -it --network host -v $(pwd):/e2e -w /e2e cypress/included:13.15.1
    

    Note: The --network host option is available on Linux. If you're using macOS or Windows, Docker's networking works differently, and you might need to use host.docker.internal to access the host machine.

  2. Use host.docker.internal: If you're on macOS or Windows, you can change the baseUrl in your cypress.config.js to use host.docker.internal, which is a special DNS name that resolves to the host machine.

    Update your cypress.config.js:

    import { defineConfig } from "cypress";
    
    export default defineConfig({
      e2e: {
        baseUrl: 'https://host.docker.internal',
        setupNodeEvents(on, config) {
          // implement node event listeners here
        },
      },
    });
    
  3. Verify SSL: If your server uses HTTPS, ensure that the SSL certificate is trusted by the Docker container. You might need to disable SSL verification in Cypress for local development:

    Add the following to your cypress.config.js:

    import { defineConfig } from "cypress";
    
    export default defineConfig({
      e2e: {
        baseUrl: 'https://host.docker.internal',
        setupNodeEvents(on, config) {
          // implement node event listeners here
        },
        // Disable SSL verification for local development
        chromeWebSecurity: false,
      },
    });
    
  4. Check Server Status: Ensure that your Laravel server is running and accessible from the host machine. You can test this by opening a browser and navigating to https://auth-server.test or https://host.docker.internal to verify that the server is up and running.

By following these steps, you should be able to resolve the issue of Cypress failing to verify that your server is running when using Docker with Laravel Herd.

Tray2's avatar

@troccoli Have you exposed the test domain to your cypress container?

Tray2's avatar

@troccoli Is the application accessible from the docker image instance

troccoli's avatar

@Tray2 I don't know.

How do I check? And how do I make it accessible if not?

Tray2's avatar

@troccoli You can probably use Expose. Is there a particular reason you don't want to install Cypress on you local machine?

troccoli's avatar

@Tray2 Only because I'm trying to understand how this will work in CI. We're using Bitbucket, so the site will be on the main pipeline image, and Cypress will run as a separate container. Expose is not an option.

Please or to participate in this conversation.