Skip to content

Vite won't restart if proxy is interrupted #8117

@wenq1

Description

@wenq1

Describe the bug

If configured with proxy, such as

server.proxy: {
    '/api':         {target: 'http://localhost:3000/'},
}

Vite won't restart when the local server is restarted, especially when server restart takes more than a few seconds (during development), throwing an error:

19:25:21 [vite] http proxy error:
Error: connect ECONNREFUSED 127.0.0.1:3000
    at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1157:16)

Reproduction

n/a

System Info

System:
    OS: macOS 12.2
    CPU: (8) x64 Apple M1
    Memory: 47.80 MB / 16.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 16.14.2 - /usr/local/opt/node@16/bin/node
    Yarn: 1.22.18 - /usr/local/bin/yarn
    npm: 8.5.0 - /usr/local/opt/node@16/bin/npm
  Browsers:
    Chrome: 101.0.4951.54
    Safari: 15.3
  npmPackages:
    @vitejs/plugin-react: ^1.1.4 => 1.2.0 
    @vitejs/plugin-react-refresh: ^1.3.6 => 1.3.6 
    vite: ^2.7.12 => 2.8.6

Used Package Manager

npm

Logs

No response

Validations

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions