Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WebSocket connection to 'ws:<URL>/_next/webpack-hmr' failed: WebSocket is closed before the connection is established

Hi am having this problem, i try to make subscriptions with graphql in nextjs, but something is wrong and i dont have any idea how fix it. I am having websocket error - "WebSocket connection to 'ws:/_next/webpack-hmr' failed: WebSocket is closed before the connection is established."

You can check code here - https://github.com/LoQeN00/messenger-2.0.git

error

graphql-setup

like image 734
Mateusz Kozłowski Avatar asked Nov 16 '25 14:11

Mateusz Kozłowski


2 Answers

I restarted my PC and this issue was resolved for me according to this post on github

like image 173
Cuado Avatar answered Nov 19 '25 06:11

Cuado


If you are using Nginx: https://nextjs.org/docs/pages/building-your-application/upgrading/version-12#hmr-connection-now-uses-a-websocket

location /_next/webpack-hmr {
    proxy_pass http://localhost:3000/_next/webpack-hmr;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
}
like image 24
meotimdihia Avatar answered Nov 19 '25 06:11

meotimdihia



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!