Deploy app with postgres: could not create lock file

Hello,

I have a problem when I try to deploy my app:

FATAL: could not create lock file “/run/postgresql/.s.PGSQL.5432.lock”: No such file or directory

I did the upgrade to postgresql 16 and it works fine locally (windows + docker).
I am really a beginner and would need at least to be pointed in the right direction: what could be causing the error?

Thanks for any hint!

Ok, I’ve deleted the app and recreated it and now it deploy and run the migrations without any error… but after that something happens…

The log, which I don’t understand…

2023-12-21T16:28:56Z app[17811e16fe5258] otp [info]  ▲ Next.js 13.5.5
2023-12-21T16:28:56Z app[17811e16fe5258] otp [info]  - Local:        http://localhost:8080
2023-12-21T16:28:56Z app[17811e16fe5258] otp [info] ✓ Ready in 691ms
2023-12-21T16:33:54Z app[17811e16fe5258] otp [info]2023-12-21 16:33:54.304 UTC [331] LOG:  checkpoint starting: time
2023-12-21T16:35:19Z proxy[17811e16fe5258] otp [info]Downscaling app opentribe from 1 machines to 0 machines, stopping machine 17811e16fe5258 (region=otp, process group=app)
2023-12-21T16:35:19Z app[17811e16fe5258] otp [info] INFO Sending signal SIGINT to main child process w/ PID 313
2023-12-21T16:35:24Z app[17811e16fe5258] otp [info] INFO Sending signal SIGTERM to main child process w/ PID 313
2023-12-21T16:35:25Z app[17811e16fe5258] otp [info] INFO Main child exited with signal (with signal 'SIGTERM', core dumped? false)
2023-12-21T16:35:25Z app[17811e16fe5258] otp [info] INFO Starting clean up.
2023-12-21T16:35:25Z app[17811e16fe5258] otp [info] INFO Umounting /dev/vdb from /pg_data
2023-12-21T16:35:25Z app[17811e16fe5258] otp [info]2023-12-21 16:35:25.610 UTC [330] LOG:  received smart shutdown request
2023-12-21T16:35:25Z app[17811e16fe5258] otp [info]2023-12-21 16:35:25.619 UTC [330] LOG:  background worker "logical replication launcher" (PID 336) exited with exit code 1
2023-12-21T16:35:25Z app[17811e16fe5258] otp [info] WARN hallpass exited, pid: 314, status: signal: 15 (SIGTERM)
2023-12-21T16:35:25Z app[17811e16fe5258] otp [info]2023/12/21 16:35:25 listening on [fdaa:3:41ab:a7b:1ad:f091:f190:2]:22 (DNS: [fdaa::3]:53)
2023-12-21T16:35:25Z app[17811e16fe5258] otp [info]2023-12-21 16:35:25.649 UTC [331] LOG:  checkpoint complete: wrote 1003 buffers (6.1%); 0 WAL file(s) added, 0 removed, 0 recycled; write=91.329 s, sync=0.015 s, total=91.349 s; sync files=347, longest=0.002 s, average=0.001 s; distance=4637 kB, estimate=4637 kB; lsn=0/1950930, redo lsn=0/19508F8
2023-12-21T16:35:25Z app[17811e16fe5258] otp [info]2023-12-21 16:35:25.649 UTC [331] LOG:  shutting down
2023-12-21T16:35:25Z app[17811e16fe5258] otp [info]2023-12-21 16:35:25.650 UTC [331] LOG:  checkpoint starting: shutdown immediate
2023-12-21T16:35:25Z app[17811e16fe5258] otp [info]2023-12-21 16:35:25.650 UTC [331] LOG:  checkpoint complete: wrote 0 buffers (0.0%); 0 WAL file(s) added, 0 removed, 0 recycled; write=0.001 s, sync=0.001 s, total=0.002 s; sync files=0, longest=0.000 s, average=0.000 s; distance=0 kB, estimate=4173 kB; lsn=0/19509A8, redo lsn=0/19509A82023-12-21T16:35:25Z app[17811e16fe5258] otp [info]2023-12-21 16:35:25.656 UTC [330] LOG:  database system is shut down
2023-12-21T16:35:26Z app[17811e16fe5258] otp [info][  393.773730] reboot: Restarting system

Hi… The “downscaling” in this message is the normal auto-stop feature, which generally is beneficial:

https://fly.io/docs/apps/autostart-stop/

It avoids having an idling machine there consuming resources.  :leaves: :leaves: :leaves: :leaves:

Ok but it’s not normal in this case, the app never went online (this is right after the first deployment).
It is shutting down for some reason and I can’t understand why…

Edit: Ok tried right now and it is not shutting down

2023-12-22T07:01:57.258 app[17811e16fe5258] otp [info] ▲ Next.js 13.5.5
2023-12-22T07:01:57.258 app[17811e16fe5258] otp [info] - Local: http://localhost:8080
2023-12-22T07:01:57.258 app[17811e16fe5258] otp [info] ✓ Ready in 682ms 

The status is deployed but the app is still not reachable.
It is possible that the link under Hostname is wrong somehow?!

It can be a little misleading in atypical cases: it will show a link there even if the app in question has no public IPs.

(I have two like that.)

What do you see in fly ips list?

VERSION         IP                      TYPE    REGION  CREATED AT 
private_v6      fdaa:3:41ab:0:1::2      private global  15h10m ago 

I guess this also shows a problem… no public ip addresses?

$ fly doctor
Testing authentication token... PASSED
Testing flyctl agent... PASSED
Testing local Docker instance... Nope        
Pinging WireGuard gateway (give us a sec)... PASSED

App specific checks for opentribe:
Checking that app has ip addresses allocated... PASSED
No public ipv4 or ipv6 ip addresses allocated to app opentribe

Build checks for opentribe:
Checking docker context size (this may take little bit)... PASSED (14 MB)
Checking for .dockerignore... PASSED

Right… The public ones are required for access via .fly.dev.


Aside: it would probably also be wise to double-check the [[services]] section of your fly.toml.

1 Like

This did the trick

fly ips allocate-v4 --shared

Even if it’s not clear to me why wasn’t automatically given a shared IPv4 address on the first deployment like documentation from your link explains.

To answer your question about my fly.toml

[http_service]
  internal_port = 8080
  force_https = true
  auto_stop_machines = true
  auto_start_machines = true

But I have another app with the same configuration and I have no problems from that one.

Thanks so much for the help!!

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.