title: Cypress not connecting to localhost
body: <p>I have a docker compose file that holds my cypress container:</p>
  <pre><code>version: '3'
  
  services:
  
    redis:
      image: redis
      ports:
        - &quot;6379&quot;
      # restart: unless-stopped
      networks:
        main:
          aliases:
            - redis
  
    postgres:
      image: postgres:12
      ports:
        - &quot;5432:5432&quot;
      env_file: ./.env
      # restart: unless-stopped
      volumes:
        - pgdata:/var/lib/postgresql/data
      networks:
        main:
          aliases:
            - postgres
  
    #access by going to localhost:16543
    #when adding a server to the serve list
    #the hostname is postgres
    #the username is postgres
    #the password is postgres
    pgadmin:
      image: dpage/pgadmin4
      links:
        - postgres
      depends_on:
        - postgres
      env_file: ./.env
      # restart: unless-stopped
      ports:
        - &quot;16543:80&quot;
      networks:
        main:
          aliases:
            - pgadmin
  
  
    celery:
      build:
        context: .
        dockerfile: Dockerfile-dev    # use docker-dev because production npm installs and npm builds
      command: python manage.py celery
      env_file: ./.env
      # restart: unless-stopped
      volumes:
        - .:/code
        - tmp:/tmp
      links:
        - redis
      depends_on:
        - redis
      networks:
        main:
          aliases:
            - celery
  
    web:
      build:
        context: .
        dockerfile: Dockerfile-dev
      command: python manage.py runserver 0.0.0.0:8000
      volumes:
        - .:/code
        - tmp:/tmp
      ports:
        - &quot;8000:8000&quot;
      env_file: ./.env
      # restart: unless-stopped
      links:
        - postgres
        - redis
        - celery
        - pgadmin
      depends_on:
        - postgres
        - redis
        - celery
        - pgadmin
      networks:
        main:
          aliases:
            - web
  
    # Cypress container
    cypress:
  
      # the Docker image to use from https://github.com/cypress-io/cypress-docker-images
      image: &quot;cypress/included:4.0.2&quot;
      depends_on:
        - web
      environment:
        # pass base url to test pointing at the web application
        - CYPRESS_BASE_URL=http://web:8000
      # share the current folder as volume to avoid copying
      working_dir: /e2e
      volumes:
        - ./:/e2e
      networks:
        main:
          aliases:
            - cypress
  
  volumes:
    pgdata:
    tmp:
  
  networks:
    main:
  </code></pre>
  <p>For some reason when I start my server and then start cypress using <code>docker-compose up --exit-code-from cypress</code> I get the following error, that I cannot seem to debug, please note my server is running, and all are on the same network <strong>main</strong></p>
  <pre><code>Cypress could not verify that this server is running:
  
    &gt; http://web:8000
  
  We are verifying this server because it has been configured as your `baseUrl`.
  
  Cypress automatically waits until your server is accessible before running tests.
  
  We will try connecting to it 3 more times...
  
  ====================================================================================================
  
    (Run Starting)
  
    ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
    │ Cypress:    4.0.2                                                                              │
    │ Browser:    Electron 78 (headless)                                                             │
    │ Specs:      1 found (login/test.spec.js)                                                       │
    └────────────────────────────────────────────────────────────────────────────────────────────────┘
  
  
  ────────────────────────────────────────────────────────────────────────────────────────────────────
                                                                                                      
    Running:  login/test.spec.js                                                              (1 of 1)
  Browserslist: caniuse-lite is outdated. Please run the following command: `yarn upgrade`
  
  
    Login Page
  
      1) Visits Page
  
  
    0 passing (671ms)
    1 failing
  
    1) Login Page Visits Page:
       CypressError: cy.visit() failed trying to load:
  
  http://127.0.0.1:8000/test/
  
  We attempted to make an http request to this URL but the request failed without a response.
  
  We received this error at the network level:
  
    &gt; Error: connect ECONNREFUSED 127.0.0.1:8000
  
  Common situations why this would fail:
    - you don't have internet access
    - you forgot to run / boot your web server
    - your web server isn't accessible
    - you have weird network configuration settings on your computer
  
  The stack trace for this error is:
  
  Error: connect ECONNREFUSED 127.0.0.1:8000
      at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1056:14)
  
  </code></pre>