cypress: Cypress will fail wit urls with a domain in the form of "*.local*"

If you try to run Cypress having set up the baseUrl as something like something.localhost or something.localsite it will not run and instead it will bring up a browser screen with a grey background, no command log window

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 16 (6 by maintainers)

Commits related to this issue

Most upvoted comments

By default any domain with the pattern *.localhost points to 127.0.0.1. This is because localhost is a loopback address, and DNS implementations have defined this behavior by default.

As a top-level domain, the name has traditionally been defined statically in host DNS implementations with address records (A and AAAA) pointing to the same loopback addresses. Any other use conflicts with widely deployed algorithms relying on this convention. – https://en.wikipedia.org/wiki/.localhost

In my experience, this behavior is respected in Firefox and Chrome, and also in Windows and Ubuntu.

Sadly when running tests with Cypress this behavior is not respected. I don’t have the gray screen as other users in this issue, but my tests fail because host cannot be reached (everything works well when using the browser without Cypress).

ksnip_20211122-145943

As a workaround I had to add manually 127.0.0.1 project.localhost to my /etc/hosts file. This fixes the issue, but misses completely the purpose of using a .localhost domain, it’s very annoying to add all your domains one by one when you have many services (typically when using a reverse proxy like Traefik).

It would be great if you can fix this, thanks in advance 😃

Released in 1.4.2.

@pmatisko Could you open a new issue detailing the exact problem you are encountering as well as the test code?