I’ve found from other topics that I can stop my machine by exiting the process. I.e.
process.exit(0)
However I would like to suspend my machines instead of stopping them. Is this possible? Would I have to use the Machines API?
I’ve found from other topics that I can stop my machine by exiting the process. I.e.
process.exit(0)
However I would like to suspend my machines instead of stopping them. Is this possible? Would I have to use the Machines API?
Hey @Probert
Yeah, it’s possible via Machines API. If you do it via /.fly/api UNIX socket you don’t need any token:
curl --unix-socket /.fly/api -X POST http://flaps/v1/apps/$FLY_APP_NAME/machines/$FLY_MACHINE_ID/suspend
Cheers, works like a charm! Much easier than I expected.
Hmm, the call seems to be failing occasionally with an error like the following:
2025-11-07T13:33:48.975 app[48e2910f061458] ams [info] WARN error serving API request: error from user's Service
2025-11-07T13:33:48.976 app[48e2910f061458] ams [info] Failed to suspend machine: TypeError: fetch failed
2025-11-07T13:33:48.976 app[48e2910f061458] ams [info] at /usr/src/app/node_modules/undici/index.js:124:13
2025-11-07T13:33:48.976 app[48e2910f061458] ams [info] at async suspendMachine (/usr/src/app/index.ts:50:22) {
2025-11-07T13:33:48.976 app[48e2910f061458] ams [info] [cause]: SocketError: other side closed
2025-11-07T13:33:48.976 app[48e2910f061458] ams [info] at Socket.onHttpSocketEnd (/usr/src/app/node_modules/undici/lib/dispatcher/client-h1.js:904:22)
2025-11-07T13:33:48.976 app[48e2910f061458] ams [info] at Socket.emit (node:events:531:35)
2025-11-07T13:33:48.976 app[48e2910f061458] ams [info] at endReadableNT (node:internal/streams/readable:1698:12)
2025-11-07T13:33:48.976 app[48e2910f061458] ams [info] at process.processTicksAndRejections (node:internal/process/task_queues:90:21) {
2025-11-07T13:33:48.976 app[48e2910f061458] ams [info] code: 'UND_ERR_SOCKET',
2025-11-07T13:33:48.976 app[48e2910f061458] ams [info] socket: {
2025-11-07T13:33:48.976 app[48e2910f061458] ams [info] localAddress: undefined,
2025-11-07T13:33:48.976 app[48e2910f061458] ams [info] localPort: undefined,
2025-11-07T13:33:48.976 app[48e2910f061458] ams [info] remoteAddress: undefined,
2025-11-07T13:33:48.976 app[48e2910f061458] ams [info] remotePort: undefined,
2025-11-07T13:33:48.976 app[48e2910f061458] ams [info] remoteFamily: undefined,
2025-11-07T13:33:48.976 app[48e2910f061458] ams [info] timeout: undefined,
2025-11-07T13:33:48.976 app[48e2910f061458] ams [info] bytesWritten: 260,
2025-11-07T13:33:48.976 app[48e2910f061458] ams [info] bytesRead: 0
2025-11-07T13:33:48.976 app[48e2910f061458] ams [info] }
2025-11-07T13:33:48.976 app[48e2910f061458] ams [info] }
2025-11-07T13:33:48.976 app[48e2910f061458] ams [info] }
And the machine stays running. Do you know what might cause this?
I’m not sure yet. I don’t see any traces for the failed requests so it looks like they didn’t even make it to Machines API.
Does it happen just for this machine or for all machines in your app?
Ok, I was able to reproduce this so it’s definitely not specific to a particular host/machine.
I have an idea what might be the reason for this behavior.
This should be fixed now. You’ll need to deploy your app so the machines pick up the new init version.
Either fly deploy or fly machine update <machine id> –yes for each machine in the app should do the trick.
Thanks once again for the quick response! I’m currently on holiday so I’ll get back to this in 2 weeks
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.