Anvil App Server; Failed to start built-in Postgres database

Hi, after installing anvil-app-server with pip on Win10 64-bit and starting an app I get this error:

Failed to start built-in Postgres database: java.lang.IllegalStateException: Process [.anvil-data\db-bin\PG-aaa7d03a0c0eb51f9510c27dc059d022\bin\initdb.exe, -A, trust, -U, postgres, -D, .anvil-data\db, -E, UTF-8] failed
More logs are available in .anvil-data\postgres.log.
Some common causes of this problem:
 - Are you launching this server as 'root' on a UNIX system?
   Postgres will not run as root; try launching the server as an ordinary user.
 - Are you running this server on an unusual architecture or OS? (Windows 10/amd64)

with Python 3.8.3 and

openjdk version "11.0.7" 2020-04-14 LTS
OpenJDK Runtime Environment Corretto-11.0.7.10.1 (build 11.0.7+10-LTS)
OpenJDK 64-Bit Server VM Corretto-11.0.7.10.1 (build 11.0.7+10-LTS, mixed mode)

postgres.err and postrgres.log are empty.

I’m not sure the app server runs on Windows. I have been able to successfully run it on a Ubuntu 20.04 VM/VPS.

Did you install virtualenv?
See my post here for more information

Thanks @jeff and @Tony.Nguyen, it must be something else - I’m running Anvil App Server successfuly on another Win10 machine without any problems, without virtualenv nor linux subsystem. It must be something else. One difference that I could think of is that on the other machine I have Postgres standalone installation - however Anvil App Server uses its own.

I found the cause - Anvil App Server uses Embedded Posgres database which is build (for Windows) using Visual Studio 2013 and thus needs Microsoft Visual C++ Redistributable Packages for Visual Studio 2013. After installing it, reboot the machine and Anvil App Server works as expected.

There might be other issues with Embedded Posgres - you can pin down the problem with running initdb.exe, -A, trust, -U, postgres, -D, .anvil-data\db, -E, UTF-8 within
.anvil-data\db-bin\PG-<…>\bin on command prompt and observe the behaviour.

1 Like

Very useful info, thanks @tomaz.turk.
I have VS 2019, it fortunately might help me prevent the issue in the first place.

A post was split to a new topic: [App Server] Failed to start built-in Postgres database

Apologies for the necro. Thanks for the commentary, I’ve tried running as @tomaz.turk suggested, but it still didn’t work for me.

I’ve commented on my post here: Running Anvil Locally as Administrator Account - Anvil Q&A - Anvil Community Forum