[Bug]: API throws Error: PostError: network-failure #630

Closed
opened 2026-02-28 19:12:00 -06:00 by GiteaMirror · 13 comments
Owner

Originally created by @andyvandesand on GitHub (Sep 13, 2023).

Verified issue does not already exist?

  • I have searched and found no existing issue

What happened?

I'm trying to connect to the api from node-red. I have loaded the module, but when trying to connect node-red crashes with the following error:

[error] Error: PostError: network-failure
at post (/usr/src/node-red/node_modules/@actual-app/api/dist/app/bundle.api.js:41180:27)
at handlers.subscribe-sign-in (/usr/src/node-red/node_modules/@actual-app/api/dist/app/bundle.api.js:40078:78)
at runHandler (/usr/src/node-red/node_modules/@actual-app/api/dist/app/bundle.api.js:41028:31)
at Module.init (/usr/src/node-red/node_modules/@actual-app/api/dist/app/bundle.api.js:40664:86)
at async Object.init (/usr/src/node-red/node_modules/@actual-app/api/dist/index.js:45:5)
at async Function node:a7a5d478d990fa82 [function 1]:6:5

I can ping the server from a shell and get a result via wget.

My biggest issue is that there is no better error message and I have no idea why this is failing. A better error message would be very helpful.

Thanks!

What error did you receive?

No response

Where are you hosting Actual?

Docker

What browsers are you seeing the problem on?

No response

Operating System

Linux

Originally created by @andyvandesand on GitHub (Sep 13, 2023). ### Verified issue does not already exist? - [X] I have searched and found no existing issue ### What happened? I'm trying to connect to the api from node-red. I have loaded the module, but when trying to connect node-red crashes with the following error: [error] Error: PostError: network-failure at post (/usr/src/node-red/node_modules/@actual-app/api/dist/app/bundle.api.js:41180:27) at handlers.subscribe-sign-in (/usr/src/node-red/node_modules/@actual-app/api/dist/app/bundle.api.js:40078:78) at runHandler (/usr/src/node-red/node_modules/@actual-app/api/dist/app/bundle.api.js:41028:31) at Module.init (/usr/src/node-red/node_modules/@actual-app/api/dist/app/bundle.api.js:40664:86) at async Object.init (/usr/src/node-red/node_modules/@actual-app/api/dist/index.js:45:5) at async Function node:a7a5d478d990fa82 [function 1]:6:5 I can ping the server from a shell and get a result via wget. My biggest issue is that there is no better error message and I have no idea why this is failing. A better error message would be very helpful. Thanks! ### What error did you receive? _No response_ ### Where are you hosting Actual? Docker ### What browsers are you seeing the problem on? _No response_ ### Operating System Linux
GiteaMirror added the bugAPI labels 2026-02-28 19:12:00 -06:00
Author
Owner

@youngcw commented on GitHub (Sep 14, 2023):

Here is some more similar errors that I cant seem to get passed

PostError: PostError: network-failure
    at postBinary (/volume1/homes/caleb/actual_test/node_modules/@actual-app/api/dist/app/bundle.api.js:41212:27)
    at async _fullSync (/volume1/homes/caleb/actual_test/node_modules/@actual-app/api/dist/app/bundle.api.js:43637:33)
    at async /volume1/homes/caleb/actual_test/node_modules/@actual-app/api/dist/app/bundle.api.js:43537:32
    at async initialFullSync (/volume1/homes/caleb/actual_test/node_modules/@actual-app/api/dist/app/bundle.api.js:43523:30)
    at async handlers.sync-budget (/volume1/homes/caleb/actual_test/node_modules/@actual-app/api/dist/app/bundle.api.js:40259:30)
    at async handlers.download-budget (/volume1/homes/caleb/actual_test/node_modules/@actual-app/api/dist/app/bundle.api.js:40247:26)
    at async handlers.api/download-budget (/volume1/homes/caleb/actual_test/node_modules/@actual-app/api/dist/app/bundle.api.js:32098:34) {
  type: 'PostError',
  reason: 'network-failure',
  meta: undefined
}
PostError: PostError: network-failure
    at postBinary (/volume1/homes/caleb/actual_test/node_modules/@actual-app/api/dist/app/bundle.api.js:41212:27)
    at async _fullSync (/volume1/homes/caleb/actual_test/node_modules/@actual-app/api/dist/app/bundle.api.js:43637:33)
    at async /volume1/homes/caleb/actual_test/node_modules/@actual-app/api/dist/app/bundle.api.js:43537:32
    at async initialFullSync (/volume1/homes/caleb/actual_test/node_modules/@actual-app/api/dist/app/bundle.api.js:43523:30)
    at async handlers.sync-budget (/volume1/homes/caleb/actual_test/node_modules/@actual-app/api/dist/app/bundle.api.js:40259:30)
    at async handlers.download-budget (/volume1/homes/caleb/actual_test/node_modules/@actual-app/api/dist/app/bundle.api.js:40247:26)
    at async handlers.api/download-budget (/volume1/homes/caleb/actual_test/node_modules/@actual-app/api/dist/app/bundle.api.js:32098:34) {
  type: 'PostError',
  reason: 'network-failure',
  meta: undefined
}
Full error details {
  message: 'PostError: network-failure',
  reason: 'network-failure',
  meta: undefined
}
/volume1/homes/caleb/actual_test/node_modules/@actual-app/api/dist/app/bundle.api.js:32103
                        throw new Error((0, _shared_errors__WEBPACK_IMPORTED_MODULE_2__.getDownloadError)(result.error));
                              ^

Error: Something went wrong trying to download that file, sorry! Visit https://actualbudget.org/contact/ for support. (reason: network-failure)
    at handlers.api/download-budget (/volume1/homes/caleb/actual_test/node_modules/@actual-app/api/dist/app/bundle.api.js:32103:31)

Node.js v18.15.0
@youngcw commented on GitHub (Sep 14, 2023): Here is some more similar errors that I cant seem to get passed ``` PostError: PostError: network-failure at postBinary (/volume1/homes/caleb/actual_test/node_modules/@actual-app/api/dist/app/bundle.api.js:41212:27) at async _fullSync (/volume1/homes/caleb/actual_test/node_modules/@actual-app/api/dist/app/bundle.api.js:43637:33) at async /volume1/homes/caleb/actual_test/node_modules/@actual-app/api/dist/app/bundle.api.js:43537:32 at async initialFullSync (/volume1/homes/caleb/actual_test/node_modules/@actual-app/api/dist/app/bundle.api.js:43523:30) at async handlers.sync-budget (/volume1/homes/caleb/actual_test/node_modules/@actual-app/api/dist/app/bundle.api.js:40259:30) at async handlers.download-budget (/volume1/homes/caleb/actual_test/node_modules/@actual-app/api/dist/app/bundle.api.js:40247:26) at async handlers.api/download-budget (/volume1/homes/caleb/actual_test/node_modules/@actual-app/api/dist/app/bundle.api.js:32098:34) { type: 'PostError', reason: 'network-failure', meta: undefined } PostError: PostError: network-failure at postBinary (/volume1/homes/caleb/actual_test/node_modules/@actual-app/api/dist/app/bundle.api.js:41212:27) at async _fullSync (/volume1/homes/caleb/actual_test/node_modules/@actual-app/api/dist/app/bundle.api.js:43637:33) at async /volume1/homes/caleb/actual_test/node_modules/@actual-app/api/dist/app/bundle.api.js:43537:32 at async initialFullSync (/volume1/homes/caleb/actual_test/node_modules/@actual-app/api/dist/app/bundle.api.js:43523:30) at async handlers.sync-budget (/volume1/homes/caleb/actual_test/node_modules/@actual-app/api/dist/app/bundle.api.js:40259:30) at async handlers.download-budget (/volume1/homes/caleb/actual_test/node_modules/@actual-app/api/dist/app/bundle.api.js:40247:26) at async handlers.api/download-budget (/volume1/homes/caleb/actual_test/node_modules/@actual-app/api/dist/app/bundle.api.js:32098:34) { type: 'PostError', reason: 'network-failure', meta: undefined } Full error details { message: 'PostError: network-failure', reason: 'network-failure', meta: undefined } /volume1/homes/caleb/actual_test/node_modules/@actual-app/api/dist/app/bundle.api.js:32103 throw new Error((0, _shared_errors__WEBPACK_IMPORTED_MODULE_2__.getDownloadError)(result.error)); ^ Error: Something went wrong trying to download that file, sorry! Visit https://actualbudget.org/contact/ for support. (reason: network-failure) at handlers.api/download-budget (/volume1/homes/caleb/actual_test/node_modules/@actual-app/api/dist/app/bundle.api.js:32103:31) Node.js v18.15.0 ```
Author
Owner

@shalak commented on GitHub (Sep 29, 2023):

Did you happen to solve this issue? I'm having similar problems to yours.

actual-poller  | (node:1) UnhandledPromiseRejectionWarning: Error: PostError: network-failure
actual-poller  |     at post (/app/node_modules/@actual-app/api/dist/app/bundle.api.js:41180:27)
actual-poller  |     at handlers.subscribe-sign-in (/app/node_modules/@actual-app/api/dist/app/bundle.api.js:40078:78)
actual-poller  |     at runHandler (/app/node_modules/@actual-app/api/dist/app/bundle.api.js:41028:31)
actual-poller  |     at Module.init (/app/node_modules/@actual-app/api/dist/app/bundle.api.js:40664:86)
actual-poller  |     at async Object.init (/app/node_modules/@actual-app/api/dist/index.js:45:5)
actual-poller  |     at async /app/script.js:5:3
actual-poller  | (node:1) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 3)

My script is a copy-paste from the docs:

// script.js
let api = require('@actual-app/api');

(async () => {
  await api.init({
    dataDir: '/app/data',
    serverURL: process.env.SERVER_URL,
    password: process.env.PASSWORD,
  })
  await api.downloadBudget(process.env.BUDGET_ID);
  
  let budget = await api.getBudgetMonth('2023-09');
  console.log(budget);

  await api.shutdown();
})();
@shalak commented on GitHub (Sep 29, 2023): Did you happen to solve this issue? I'm having similar problems to yours. ``` actual-poller | (node:1) UnhandledPromiseRejectionWarning: Error: PostError: network-failure actual-poller | at post (/app/node_modules/@actual-app/api/dist/app/bundle.api.js:41180:27) actual-poller | at handlers.subscribe-sign-in (/app/node_modules/@actual-app/api/dist/app/bundle.api.js:40078:78) actual-poller | at runHandler (/app/node_modules/@actual-app/api/dist/app/bundle.api.js:41028:31) actual-poller | at Module.init (/app/node_modules/@actual-app/api/dist/app/bundle.api.js:40664:86) actual-poller | at async Object.init (/app/node_modules/@actual-app/api/dist/index.js:45:5) actual-poller | at async /app/script.js:5:3 actual-poller | (node:1) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 3) ``` My script is a copy-paste from the docs: ```js // script.js let api = require('@actual-app/api'); (async () => { await api.init({ dataDir: '/app/data', serverURL: process.env.SERVER_URL, password: process.env.PASSWORD, }) await api.downloadBudget(process.env.BUDGET_ID); let budget = await api.getBudgetMonth('2023-09'); console.log(budget); await api.shutdown(); })(); ```
Author
Owner

@youngcw commented on GitHub (Sep 29, 2023):

I don't know what causes this, but I get it about 50% of the time. I get it less when connecting via localhost.

@youngcw commented on GitHub (Sep 29, 2023): I don't know what causes this, but I get it about 50% of the time. I get it less when connecting via localhost.
Author
Owner

@andyvandesand commented on GitHub (Sep 29, 2023):

I've given up on this for the time being unfortunately, just no spare time. Without better error messages there isn't much I was able to do.

@andyvandesand commented on GitHub (Sep 29, 2023): I've given up on this for the time being unfortunately, just no spare time. Without better error messages there isn't much I was able to do.
Author
Owner

@cpainchaud commented on GitHub (Oct 23, 2023):

I do get same error message, I added a console.log on it:

TypeError: (0 , _platform_server_fetch__WEBPACK_IMPORTED_MODULE_0__.fetch) is not a function                                                                     
    at post (C:\Users\xxx\Documents\perso\export-to-mybudget\node_modules\@actual-app\api\dist\app\bundle.api.js:41169:95)                      
    at handlers.subscribe-sign-in (C:\Users\xxx\Documents\perso\export-to-mybudget\node_modules\@actual-app\api\dist\app\bundle.api.js:40078:78)
    at runHandler (C:\Users\xxx\Documents\perso\export-to-mybudget\node_modules\@actual-app\api\dist\app\bundle.api.js:41028:31)                
    at Module.init (C:\Users\xxx\Documents\perso\export-to-mybudget\node_modules\@actual-app\api\dist\app\bundle.api.js:40664:86)               
    at async Object.init (C:\Users\xxx\Documents\perso\export-to-mybudget\node_modules\@actual-app\api\dist\index.js:45:5)                      
    at async C:\Users\xxx\Documents\perso\export-to-mybudget\cli.js:4:3

somewhat it seems that i cannot find a proper HTTP library? the GETTER function exists but return undefined

@cpainchaud commented on GitHub (Oct 23, 2023): I do get same error message, I added a console.log on it: ``` TypeError: (0 , _platform_server_fetch__WEBPACK_IMPORTED_MODULE_0__.fetch) is not a function at post (C:\Users\xxx\Documents\perso\export-to-mybudget\node_modules\@actual-app\api\dist\app\bundle.api.js:41169:95) at handlers.subscribe-sign-in (C:\Users\xxx\Documents\perso\export-to-mybudget\node_modules\@actual-app\api\dist\app\bundle.api.js:40078:78) at runHandler (C:\Users\xxx\Documents\perso\export-to-mybudget\node_modules\@actual-app\api\dist\app\bundle.api.js:41028:31) at Module.init (C:\Users\xxx\Documents\perso\export-to-mybudget\node_modules\@actual-app\api\dist\app\bundle.api.js:40664:86) at async Object.init (C:\Users\xxx\Documents\perso\export-to-mybudget\node_modules\@actual-app\api\dist\index.js:45:5) at async C:\Users\xxx\Documents\perso\export-to-mybudget\cli.js:4:3 ``` somewhat it seems that i cannot find a proper HTTP library? the GETTER function exists but return undefined
Author
Owner

@davidhsv commented on GitHub (Oct 23, 2023):

I had this error and it stopped after I changed the nvm to v18.18.2 (it was v14.20.0)

@davidhsv commented on GitHub (Oct 23, 2023): I had this error and it stopped after I changed the nvm to v18.18.2 (it was v14.20.0)
Author
Owner

@cpainchaud commented on GitHub (Oct 24, 2023):

I had this error and it stopped after I changed the nvm to v18.18.2 (it was v14.20.0)

thank you! I was using v16 and switching to v14 has fixed my issue!

@cpainchaud commented on GitHub (Oct 24, 2023): > I had this error and it stopped after I changed the nvm to v18.18.2 (it was v14.20.0) thank you! I was using v16 and switching to v14 has fixed my issue!
Author
Owner

@youngcw commented on GitHub (Oct 25, 2023):

I moved my api scripts to my desk machine running node v18.18.2 and everything cleared up. Node v18.15.0 on my synology box was the version throwing errors.

@youngcw commented on GitHub (Oct 25, 2023): I moved my api scripts to my desk machine running node v18.18.2 and everything cleared up. Node v18.15.0 on my synology box was the version throwing errors.
Author
Owner

@phouse512 commented on GitHub (Oct 29, 2023):

I ran into this error as well, and built it locally to figure out what the actual error was in my case. It was due to a self-signed cert inside my local network. Here is the full error I logged out:

      at TLSSocket.onConnectSecure (node:_tls_wrap:1600:34)
      at TLSSocket.emit (node:events:517:28)
      at TLSSocket._finishInit (node:_tls_wrap:1017:8)
      at ssl.onhandshakedone (node:_tls_wrap:803:12) {
    code: 'DEPTH_ZERO_SELF_SIGNED_CERT'
  }
}

In my case, since this is all a private network, I'm ok with moving forward, so the best way I found to work around it was to set the following environment variable to 0, then the command worked as expected!

NODE_TLS_REJECT_UNAUTHORIZED=0

@phouse512 commented on GitHub (Oct 29, 2023): I ran into this error as well, and built it locally to figure out what the actual error was in my case. It was due to a self-signed cert inside my local network. Here is the full error I logged out: ``` cause: Error: self-signed certificate at TLSSocket.onConnectSecure (node:_tls_wrap:1600:34) at TLSSocket.emit (node:events:517:28) at TLSSocket._finishInit (node:_tls_wrap:1017:8) at ssl.onhandshakedone (node:_tls_wrap:803:12) { code: 'DEPTH_ZERO_SELF_SIGNED_CERT' } } ``` In my case, since this is all a private network, I'm ok with moving forward, so the best way I found to work around it was to set the following environment variable to 0, then the command worked as expected! ```NODE_TLS_REJECT_UNAUTHORIZED=0```
Author
Owner

@dylanlive commented on GitHub (Nov 29, 2023):

In my case, since this is all a private network, I'm ok with moving forward, so the best way I found to work around it was to set the following environment variable to 0, then the command worked as expected!

NODE_TLS_REJECT_UNAUTHORIZED=0

+1, thanks! I set up https per the instructions as this is running on a raspberry pi. Example: NODE_TLS_REJECT_UNAUTHORIZED=0 node index.js

Interestingly, this still didn't work for me on Node v18.16.0 until I upgraded to Node v20.10.0

@dylanlive commented on GitHub (Nov 29, 2023): >In my case, since this is all a private network, I'm ok with moving forward, so the best way I found to work around it was to set the following environment variable to 0, then the command worked as expected! > >`NODE_TLS_REJECT_UNAUTHORIZED=0` +1, thanks! I set up https [per the instructions](https://actualbudget.org/docs/config/https) as this is running on a raspberry pi. Example: `NODE_TLS_REJECT_UNAUTHORIZED=0 node index.js` Interestingly, this still didn't work for me on `Node v18.16.0` until I upgraded to `Node v20.10.0`
Author
Owner

@axelson commented on GitHub (Oct 13, 2024):

I think I'm running into this same issue, but NODE_TLS_REJECT_UNAUTHORIZED=0 isn't resolving it for me (and I've tested on many node.js versions, including 20.10.0). I'm using the default API script that's been posted multiple times throughout this thread and when I modify the bundled js to print out the detailed error I get:

Loading fresh spreadsheet                                                                                                                                                                                  
Syncing since 2024-10-13T03:55:59.116Z-0000-0000000000000000 0 (attempt: 0)
error TypeError: fetch failed
    at Object.fetch (node:internal/deps/undici/undici:11730:11)
    at async postBinary (/home/jason/actual_mobile/node_modules/@actual-app/api/dist/app/bundle.api.js:43570:27)                               
    at async _fullSync (/home/jason/actual_mobile/node_modules/@actual-app/api/dist/app/bundle.api.js:46432:35)             
    at async /home/jason/actual_mobile/node_modules/@actual-app/api/dist/app/bundle.api.js:46333:32
    at async initialFullSync (/home/jason/actual_mobile/node_modules/@actual-app/api/dist/app/bundle.api.js:46319:32)
    at async handlers.sync-budget (/home/jason/actual_mobile/node_modules/@actual-app/api/dist/app/bundle.api.js:42611:32)
    at async handlers.download-budget (/home/jason/actual_mobile/node_modules/@actual-app/api/dist/app/bundle.api.js:42599:26)
    at async handlers.api/download-budget (/home/jason/actual_mobile/node_modules/@actual-app/api/dist/app/bundle.api.js:32823:32) {
  cause: SocketError: other side closed
      at Socket.onSocketEnd (node:internal/deps/undici/undici:8280:26)
      at Socket.emit (node:events:526:35)
      at endReadableNT (node:internal/streams/readable:1589:12)
      at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
    code: 'UND_ERR_SOCKET',
    socket: {
      localAddress: '127.0.0.1',
      localPort: 55074,
      remoteAddress: '127.0.0.1',
      remotePort: 5006,
      remoteFamily: 'IPv4',
      timeout: undefined,
      bytesWritten: 955,
      bytesRead: 1125
    }
  }
}

But the strange thing is the same exact script runs successfully if I run it on a different computer. So it fails if I run it on the same linux/host server that is running Actual (via Docker), but it succeeds when I run it from my linux desktop computer or macos laptop.

@axelson commented on GitHub (Oct 13, 2024): I _think_ I'm running into this same issue, but `NODE_TLS_REJECT_UNAUTHORIZED=0` isn't resolving it for me (and I've tested on many node.js versions, including 20.10.0). I'm using the default API script that's been posted multiple times throughout this thread and when I modify the bundled js to print out the detailed error I get: ``` Loading fresh spreadsheet Syncing since 2024-10-13T03:55:59.116Z-0000-0000000000000000 0 (attempt: 0) error TypeError: fetch failed at Object.fetch (node:internal/deps/undici/undici:11730:11) at async postBinary (/home/jason/actual_mobile/node_modules/@actual-app/api/dist/app/bundle.api.js:43570:27) at async _fullSync (/home/jason/actual_mobile/node_modules/@actual-app/api/dist/app/bundle.api.js:46432:35) at async /home/jason/actual_mobile/node_modules/@actual-app/api/dist/app/bundle.api.js:46333:32 at async initialFullSync (/home/jason/actual_mobile/node_modules/@actual-app/api/dist/app/bundle.api.js:46319:32) at async handlers.sync-budget (/home/jason/actual_mobile/node_modules/@actual-app/api/dist/app/bundle.api.js:42611:32) at async handlers.download-budget (/home/jason/actual_mobile/node_modules/@actual-app/api/dist/app/bundle.api.js:42599:26) at async handlers.api/download-budget (/home/jason/actual_mobile/node_modules/@actual-app/api/dist/app/bundle.api.js:32823:32) { cause: SocketError: other side closed at Socket.onSocketEnd (node:internal/deps/undici/undici:8280:26) at Socket.emit (node:events:526:35) at endReadableNT (node:internal/streams/readable:1589:12) at process.processTicksAndRejections (node:internal/process/task_queues:82:21) { code: 'UND_ERR_SOCKET', socket: { localAddress: '127.0.0.1', localPort: 55074, remoteAddress: '127.0.0.1', remotePort: 5006, remoteFamily: 'IPv4', timeout: undefined, bytesWritten: 955, bytesRead: 1125 } } } ``` But the strange thing is the same exact script runs successfully if I run it on a different computer. So it fails if I run it on the same linux/host server that is running Actual (via Docker), but it succeeds when I run it from my linux desktop computer or macos laptop.
Author
Owner

@axelson commented on GitHub (Oct 13, 2024):

After some more testing it does seem to be a timing issue. If I add an artificial delay of 1 second, or add a network request right before the failing request, then everything succeeds.

@axelson commented on GitHub (Oct 13, 2024): After some more testing it _does_ seem to be a timing issue. If I add an artificial delay of 1 second, or add a network request right before the failing request, then everything succeeds.
Author
Owner

@axelson commented on GitHub (Oct 11, 2025):

FYI after updating to 25.10.0 I don't need the patch above anymore.

@axelson commented on GitHub (Oct 11, 2025): FYI after updating to 25.10.0 I don't need the patch above anymore.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/actual#630