LiteFS "wal error: read only replica" on a POST Request

No… The LiteFS proxy, which runs within your Machine, should be doing that itself.

The screenshot from your earlier post does show it listening on the correct port, so I think this might be a case of the outer Fly edge proxy having partially stale metadata.

Could you try changing proxy.target in litefs.yml back to 8081? I know you switched it to 3000 to avoid (seemingly) spurious warnings in the logs, but it looks like it might be more substantive…


Aside: You can see a redirection in detail via:

$ fly ssh console --select  # select non-primary
# cat /litefs/.primary
432189ff765432
# curl -i -X POST http://localhost:8080/endpoint
HTTP/1.1 200 OK
Fly-Replay: instance=432189ff765432
Date: Sun, 25 Aug 2024 21:13:48 GMT
Content-Length: 0

The Fly edge proxy will notice the Fly-Replay entry and then send the client’s original request (the one that came in via app-name.fly.dev) to 432189ff765432 instead.