cli: 'socket hang up' error thrown randomly
- Do you want to request a feature or report a bug?
Bug
- What is the current behavior?
At points during development the following error occurs which stops the entire Netlify Dev stack:
.../node_modules/netlify-redirector/lib/redirects.js:116
throw ex;
^
Error: socket hang up
at createHangUpError (_http_client.js:323:15)
at Socket.socketCloseListener (_http_client.js:364:25)
at Socket.emit (events.js:194:15)
at TCP._handle.close (net.js:600:12)
Looks like it was also reported on the community forum back in April - https://community.netlify.com/t/netlify-dev-regularly-crashes/551
- If the current behavior is a bug, please provide the steps to reproduce.
I haven’t been able see any common pattern for what causes this.
- What is the expected behavior?
Should not crash.
- Please mention your node.js, and operating system version.
- Node:
v10.15.1 - Using
yarn - Netlify CLI
2.12.0
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 47
- Comments: 57 (12 by maintainers)
Commits related to this issue
- Figuring out Netlify dev server issues https://github.com/netlify/cli/issues/404#issuecomment-581163846 — committed to miohtama/capitalgram by miohtama 4 years ago
We’ve just published a new version (2.37.0). Please update and let us know if it works for you.
For anyone watching this, it’s now top priority 👍 Updates soon.
Adding onto what @pushred mentioned above; it’d be great if the port could also be shut-down in the event an error is caught - re-googling
sudo lsof -i tcp:3000andkill -QUIT <PID>is sadly something I will never memorize and is the bane of my existence.Yah, I’m getting this as well. For anyone on mac, if you don’t have any other node processes running,
killall nodesaves me from having to uselsof. Use it with caution though obviously.The issue seems like an unhandled error isn’t been returned properly somewhere, but I haven’t been able to specifically isolate when it happens.
For me this occurs when I change a function:
…or a CRA src file:
Version: netlify-cli/2.13.0 darwin-x64 node-v10.15.3
It’s also worth noting that with CRA at least it’s processes remain running after the crash and must be killed before
netlify devcan start again.until this is fixed it seems that Netlify Dev is unusable for me. i am having the same issue, either in the browser or postman i can call a function one time then the server dies with this same message .
heres an example function endpoint :
localhost:8888/.netlify/functions/login
im using macos
We’ve discovered a cure-all fix for this problem. And it is in the pipeline to be released soon. Please hold on.
I’m experimenting the same crash on macOS (
netlify-cli/2.30.0 darwin-x64 node-v12.10.0), running a react app.Note that if you’re like me and find that Netlify Dev opening a new browser tab every time it restarts is annoying (and thus closing the tab immediately, causing Netlify Dev to crash), you can set the
autoLaunchparam tofalsein yournetlify.tomlfile’s[dev]block to prevent this behavior.this thread in Community should also be updated when we have a fix. Thanks @erquhart .
https://community.netlify.com/t/error-socket-hang-up-is-there-a-cure-for-random-socket-errors/9586/2
@raeesbhatti So far, I figured out a reliable way to recreate socket hang up errors only on the initial run of
netlify dev, but I’m hoping this offers us some breadcrumbs.socket hang uperrors) a.npm install -g ionicb.ionic startc. Provide a name, selectreact, selectsidemenud.cdinto the newly created directorynetlify dev, then immediately go do weird things with localhost:8888 in the browser. What I mean by that: a. Runnetlify dev, then as soon as browser opens localhost:8888, close the browser tab => socket hang up error b. OR have localhost:8888 already open in another tab, runnetlify dev, and spam the refresh button on the existing localhost:8888 tab (while the new localhost:8888 tab is popping up) => socket hangup errorOne thing I have noticed before is that once I get a socket hangup error, I seem to get a bunch of them in a row (where I’m unable to run
netlify devfor like 5-10 min straight). This makes me wonder…netlify devopens a new browser tab for localhost:8888 every time…if I don’t close the old tabs, am I essentially experiencing the behavior outlined in (2b) above?
And if so, is something similar happening if I have multiple browser tabs opened for localhost:8888?
…the mystery continues!
This has been happening to me as well. It looks like netlify-redirector isn’t open source, so it isn’t even possible to try to debug the root of the issue.
yes, I’m getting this repeatedly, every edit almost
Hi! We’ve released version 3.4.2 just now, which should fix this problem. In case someone is still experiencing it after upgrading, please reopen the issue.
Thanks! 🙌🏻
@abtx @zb2oby @t2ca not sure about your case, but maybe this link can help you - https://github.com/netlify/netlify-faunadb-example/issues/15.
The fix seems to be working for me! Thanks!
Sure 😃
hello, Same problem with faunadb request after deployment on src change
request to https://db.fauna.com/ failed, reason: socket hang upLooks like the culrpint to the pain is Netlify dev server and its proxy. You can go ahead without the proxy. Here is my workaround.
Use
netlify-lambdainstead of Netlify dev server.npx netlify-lambda serve src/functionsIt will listen for API function calls in localhost:9000.
In another port start
npx eleventy --serve. It will listen to the page request in localhost:8080.In all your source files, have a switch between
prodandenvthat will write API function URLs differently depending are you running them locally or not.