Unable to access capybara server from service container with browser - cucumber scenarios

I am trying to setup github actions workflow for cucumber testing that uses browser service container. Locally everything works great, but whatever I try it does not work on github. Regular scenarios are passing, but scenarios with tagged with @javascript are failing with error that can’t connect.

 @javascript
  Scenario: Can't create client with invalid data                           # features/admin/client_management.feature:17
    Given I am logged in as Admin user                                      # features/step_definitions/shared/authentication_steps.rb:29
      Failed to open TCP connection to web:3001 (getaddrinfo: Temporary failure in name resolution) (SocketError)

What’s bothering me even more is that some of the scenarios tagged with @javascript are passing.

This is docker-compose.yml

version: '3.8'

services:
  web:
    tty: true
    stdin_open: true
    build: .
    command: bundle exec rails s -p 3000 -b '0.0.0.0'
    volumes:
      - .:/app
      - bundle_volume:/usr/local/bundle
    ports:
      - "3000:3000"
    depends_on:
      - db
      - browser

  db:
    image: postgres:12
    volumes:
      - db_volume:/var/lib/postgresql/data
    ports:
      - "5432:5432"
    environment:
      POSTGRES_PASSWORD: password1234

  browser:
    image: selenium/standalone-chrome-debug

    ports:
      - "5900:5900" #for VNC access
      - "4444:4444" #for webdriver access

volumes:
  bundle_volume:
  db_volume: 

this is my driver configuration features/support/env.rb

Capybara.register_driver :remote_chrome do |app|
  Capybara::Selenium::Driver.new(app,
                                 browser: :remote,
                                 capabilities: :chrome,
                                 url: 'http://browser:4444/wd/hub')
end

Capybara.configure do |config|
  config.run_server = true
  config.javascript_driver = :remote_chrome
  config.app_host = 'http://web:3001'
  config.server_host = 'web'
  config.server_port = '3001'
  config.always_include_port = true
  config.default_max_wait_time = 4
end

And finally this is the workflow file(at least my try, cucumber runner is at the end) .github/workflows/tests.yml

name: Tests

on: [push]

jobs:
  build:
    runs-on: ubuntu-latest

    services:
      postgres:
        image: postgres:12
        env:
          POSTGRES_USER: postgres
          POSTGRES_PASSWORD: password1234
        ports:
        # will assign a random free host port
        - 5432/tcp
        # needed because the postgres container does not provide a healthcheck
        options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
      browser:
        image: selenium/standalone-chrome-debug

        ports:
          - "5900:5900" #for VNC access
          - "4444:4444" #for webdriver access

    steps:
    - uses: actions/checkout@v2
    - uses: actions/cache@v1
      with:
        path: vendor/bundle
        key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
        restore-keys: |
          ${{ runner.os }}-gems-
    - uses: ruby/setup-ruby@v1
      with:
        ruby-version: 3.0.1
    - name: Install postgres client
      run: |
        sudo apt-get install libpq-dev
    - name: Install dependencies
      run: |
        gem install bundler
        bundle config path vendor/bundle
        bundle install --jobs 4 --retry 3
    - uses: borales/actions-yarn@v2.3.0
      with:
        cmd: install
    - name: Create test database
      run: |
        cp config/database.yml.github config/database.yml
        bundler exec rails db:create
        bundler exec rails db:schema:load
      env:
        RAILS_ENV: test
        POSTGRES_HOST: localhost
        POSTGRES_PORT: ${{ job.services.postgres.ports[5432] }} # get randomly assigned published port
    - name: Run tests
      run: |
        bundler exec rspec
      env:
        RAILS_ENV: test
        POSTGRES_HOST: localhost
        POSTGRES_PORT: ${{ job.services.postgres.ports[5432] }} # get randomly assigned published port
    - name: Run scenarios
      run: |
        bundler exec cucumber --retry 3
      env:
        RAILS_ENV: test
        POSTGRES_HOST: localhost
        POSTGRES_PORT: ${{ job.services.postgres.ports[5432] }} 

Any idea, suggestion, link to some guide/example, guide how to debug is more then welcome. I am struggling with this for quite some time.

Thanks in advance.