Cypress could not verify that the server set as your 'baseUrl' is running:

I can reach from my computer with web browser to xxxx.com:8089 which is running on a container too but different remote machine. Everything is fine. My cypress.json

"baseUrl": "http://xxxx.com:8089" is this.

I am trying to run docker container to run tests with Cypress :

docker run --rm --name burak --ipc="host" -w /hede -v /Users/kurhanb/Desktop/nameoftheProject:/hede' cypress /bin/bash -c cypress run --browser chrome && chmod -R 777 . --reporter mochawesome --reporter-options --reportDir=Users/kurhanb/Desktop/CypressTest overwrite=false 

It gives me :

Cypress could not verify that the server set as your 'baseUrl' is running:

http://xxxx.com

Your tests likely make requests to this 'baseUrl' and these tests will fail if you don't boot your server.

So basically, I can reach from my computer but container can not ?

3

6 Answers

Cypress is giving you that error because at the time that Cypress starts, your application is not yet ready to start responding to requests.

Let's say your application takes 10 seconds to set up and start responding to requests. If you start your application and Cypress at the exact same time, Cypress will not be able to reach your application for the first ten seconds. Rather then wait indefinitely for the app to come online, Cypress will exit and tell you that your app is not yet online.

The way to fix this problem is to make sure that your web server is serving before Cypress ever turns on. The Cypress docs have some examples of how you can make this happen: https://docs.cypress.io/guides/guides/continuous-integration.html#Boot-your-server

0

I got the "Cypress failed to verify that your server is running" problem despite being able to access the site through a browser. The problem was that my

/etc/hosts 

file did not include a line:

127.0.0.1 localhost 

If you are trying to run your test on a preview/staging environment and you can reach it manually, the problem can be your proxy settings. Try to add the domain to / IP address to NO_PROXY:

set NO_PROXY="your_company_domain.com" 

If you navigate to the Proxy Settings in the test runner, you should see the Proxy Server and a Proxy Bypass List, with the NO_PROXY values.

I hope it helps somebody. Happy coding.

2

In your CICD pipeline, make sure your application is up and running before Cypress.

Using Vue.js app as example, use following commands in CICD pipeline scripts:

npm install -g wait-on npm run serve & wait-on http://localhost:8080 cypress run 

I faced the same issue when i was working on a react application with gitlab ci and docker image. React application have default port as 3000, but some how docker image was assigning default port 5000. So i used cross-env to change default port of react app to 5000: - Steps

  • download cross-env package
  • in package.json file under script change 'start': 'react-scripts start' to 'start': 'cross-env PORT=5000 react-scripts start'
  • Also, if working with docker, you need to make sure that your front-end and back-end are working. Cypress doesn't automatically starts your front-end server. Steps should be

  • npm start
  • npm start < back-end>
  • npx cypress run or npx cypress open
  • I tried the suggestions above, with no success. I think this is a docker issue as restarting docker fixed it for me.

    2

    ncG1vNJzZmirpJawrLvVnqmfpJ%2Bse6S7zGiorp2jqbawutJobGxxZW6GeoGOnLCpqpWowG6vzq6jnWWepMFuwsSroJ%2BxXam1osCMrZ%2BeZaOav7ex0WaqnqxdlsBuxc6uqWaakaiytr7LZqCsZaKqu6%2B1zaA%3D