WebSocket connection to 'ws://localhost:8443/' failed: Error during WebSocket handshake: Unexpected response code: 400
error on browser
Can you provide more info? Your issue does not detail your error. I also need your diagnostic information
I clone the repo and build it locally for the latest updates when I start it on browser console it showing the above error.
This does not tell the whole picture. We need the following:
We can't help you if you don't have these prerequisites - it helps us to get a better picture and allow to reproduce it.
I also want to point out you might have WebRTC disabled as well - check if you have a WebRTC blocker. If you do, you can't use code-server.
I'm also seeing this. I'm using MacOS 10.14.
This is what I did:
git clone https://github.com/codercom/code-server.git
cd code-server
yarn
yarn task build:server:binary
yarn start
https://localhost:8443/ just shows a black screen forever, and the JS console repeatedly prints every few seconds:
WebSocket connection to 'ws://localhost:8443/' failed: Error during WebSocket handshake: Unexpected response code: 400
(anonymous) @ client.ts:110
step @ tslib.es6.js:117
(anonymous) @ tslib.es6.js:98
(anonymous) @ tslib.es6.js:91
__awaiter @ tslib.es6.js:87
WebsocketConnection.openSocket @ client.ts:103
(anonymous) @ client.ts:63
step @ tslib.es6.js:117
(anonymous) @ tslib.es6.js:98
(anonymous) @ tslib.es6.js:91
__awaiter @ tslib.es6.js:87
WebsocketConnection.connect @ client.ts:58
(anonymous) @ client.ts:17
Retry.runItem @ retry.ts:164
(anonymous) @ retry.ts:126
I'm at commit 742dd6f.
CC @Multishifties if this is known
This is a known Error. Unfortunately I have yet to determine the cause of this.
@nishantbhat May I suggest you change this title to WebSocket handshake: Unexpected response code: 400 so that other users may find it and avoid duplicate issues? (please?)
I had same situation, but I turned on and off a few times and wait a minute. then it was fixed.
but I don't know why.
I use CentOS 7.x, and used https://github.com/cdr/code-server/commit/72152f74ab3a9d06ee42f693e191049ad13709ea commit
yarn
yarn task build:server:binary
yarn start
INFO webpack {"message":"wait until bundle finished: /"}
webpack built 914fd503f1fcdf6cd102 in 21813ms
WARN webpack {"message":"\nWARNING in ./lib/vscode/src/vs/workbench/services/extensions/electron-browser/cachedExtensionScanner.ts 326:96-103\nCritical dependency: require function is used in a way in which dependencies cannot be statically extracted\n\nWARNING in ./lib/vscode/src/vs/platform/environment/node/environmentService.ts 76:74-81\nCritical dependency: require function is used in a way in which dependencies cannot be statically extracted\n\nWARNING in ./lib/vscode/src/vs/workbench/contrib/debug/node/debugger.ts 259:72-79\nCritical dependency: require function is used in a way in which dependencies cannot be statically extracted\n\nWARNING in ./lib/vscode/src/vs/workbench/contrib/cli/node/cli.contribution.ts 30:46-53\nCritical dependency: require function is used in a way in which dependencies cannot be statically extracted\n\nWARNING in ./lib/vscode/src/vs/workbench/contrib/performance/electron-browser/perfviewEditor.ts 243:39-46\nCritical dependency: require function is used in a way in which dependencies cannot be statically extracted\n\nWARNING in ./lib/vscode/src/vs/workbench/contrib/externalTerminal/electron-browser/externalTerminalService.ts 113:60-67\nCritical dependency: require function is used in a way in which dependencies cannot be statically extracted\n\nWARNING in ./lib/vscode/src/vs/base/node/processes.ts 54:49-56\nCritical dependency: require function is used in a way in which dependencies cannot be statically extracted\n\nWARNING in ./lib/vscode/src/vs/workbench/services/extensions/electron-browser/cachedExtensionScanner.ts 31:84-91\nCritical dependency: require function is used in a way in which dependencies cannot be statically extracted\n\nWARNING in ./lib/vscode/src/vs/workbench/services/extensions/electron-browser/cachedExtensionScanner.ts 38:92-99\nCritical dependency: require function is used in a way in which dependencies cannot be statically extracted\n\nWARNING in ./lib/vscode/src/vs/platform/environment/node/environmentService.ts 183:75-82\nCritical dependency: require function is used in a way in which dependencies cannot be statically extracted\n\nWARNING in ./lib/vscode/src/vs/workbench/services/extensions/electron-browser/extensionHost.ts 143:94-101\nCritical dependency: require function is used in a way in which dependencies cannot be statically extracted\n\nWARNING in ./lib/vscode/node_modules/getmac/index.js 3:63-70\nCritical dependency: require function is used in a way in which dependencies cannot be statically extracted\n\nWARNING in ./lib/vscode/src/vs/workbench/services/files/node/watcher/win32/csharpWatcherService.ts 35:58-65\nCritical dependency: require function is used in a way in which dependencies cannot be statically extracted\n\nWARNING in ./lib/vscode/src/vs/workbench/services/files/node/watcher/nsfw/watcherService.ts 30:68-75\nCritical dependency: require function is used in a way in which dependencies cannot be statically extracted\n\nWARNING in ./lib/vscode/src/vs/workbench/services/files/node/watcher/unix/watcherService.ts 31:68-75\nCritical dependency: require function is used in a way in which dependencies cannot be statically extracted\n\nWARNING in ./lib/vscode/src/vs/workbench/services/search/node/searchService.ts 412:72-79\nCritical dependency: require function is used in a way in which dependencies cannot be statically extracted\n\nWARNING in ./lib/vscode/src/vs/workbench/contrib/debug/node/terminals.ts 124:60-67\nCritical dependency: require function is used in a way in which dependencies cannot be statically extracted\n\nWARNING in ./lib/vscode/src/vs/editor/common/services/editorSimpleWorker.ts 464:12-474:22\nCritical dependency: the request of a dependency is an expression\n\nWARNING in ./lib/vscode/node_modules/vscode-textmate/release/main.js 14:15-27\nCritical dependency: the request of a dependency is an expression"}
INFO webpack {"message":"Compiled with warnings."}
INFO WebSocket opened / {"client":1,"ip":"🚫"}
INFO WebSocket closed / {"client":1,"code":1001}
INFO Wrote resource {"path":"🚫/code-server/User/workspaceStorage/1fab9dc45b76f1e6a06b4bc07a1e63c6/state.json","content-length":2}
INFO WebSocket opened / {"client":2,"ip":"🚫"}
From what I can tell this might be a misconfigured reverse proxy, or the network is actively blocking WebRTC requests.
Issue is marked stale. Closing as no longer relevant to current tree.
Description
Related Issues
WebSocket connection to 'ws://localhost:8443/' failed: Error during WebSocket handshake: Unexpected response code: 400
error on browser
Hey, mate, I have faced same issue with Unexpected response code: 200. My app is running behind nginx reversed proxy. I have changed setting to this, and it works for me. I think proxy_pass needs to set to localhost. Hope this will help you out. Happy coding ~~~
location / {
proxy_pass http://localhost:8080;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
}
Sorry newbie here, do I just add this to my nginx.config or do I paste it inside/merge it with one of the existing sections (e.g. events { .. }, http { .. })?
@wesleytian It should be inside a server block. For example: https://github.com/cdr/code-server/blob/master/doc/quickstart.md#nginx-reverse-proxy
And for completeness server blocks go inside the http block.
Description
Related Issues
WebSocket connection to 'ws://localhost:8443/' failed: Error during WebSocket handshake: Unexpected response code: 400
error on browserHey, mate, I have faced same issue with Unexpected response code: 200. My app is running behind nginx reversed proxy. I have changed setting to this, and it works for me. I think proxy_pass needs to set to localhost. Hope this will help you out. Happy coding ~~~
location / {
proxy_pass http://localhost:8080;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
}
Thank you @soymikey! This works for me.
This issue should be opened because it has not been resolved.
This issue should be opened because it has not been resolved.
Please try to use our setup guide with caddy instead. No evidence of a bug with code-server in this issue.
Most helpful comment
Hey, mate, I have faced same issue with Unexpected response code: 200. My app is running behind nginx reversed proxy. I have changed setting to this, and it works for me. I think proxy_pass needs to set to localhost. Hope this will help you out. Happy coding ~~~
location / {
proxy_pass http://localhost:8080;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
}