AI-coded apps

    Bolt.new: fixing 'Error initializing database' on iOS

    A 2026 view of a Bolt.new iOS app throwing Error initializing database, with the common causes shown: missing config, an App Transport Security block, a localhost address, and an init race

    "Error initializing database" almost always means the database client never connected, and on iOS the cause is usually one of a few predictable things rather than a deep bug. A Bolt.new app that works in the web preview can hit this on a real device because the configuration, the network rules, or the startup order differ once it is a native iOS build. The good news is that the suspects are short and checkable. Here is what the error means and how to work through the common causes.

    Short answer

    "Error initializing database" in a Bolt.new iOS app means the database client failed to start, and the usual causes are a missing or wrong configuration for the iOS build, a connection blocked by App Transport Security, a config still pointing at localhost, or the app using the database before it finished initializing. The fix is to confirm the database URL and keys are actually present in the iOS build, ensure the endpoint is HTTPS so App Transport Security allows it, replace any localhost address with a reachable host, and make sure initialization completes before the first query. Work through those in order and the error usually resolves.

    What you should know

    • It means the client did not connect: the database failed to initialize.
    • Web preview is not the device: config and network rules differ on iOS.
    • Config is the top suspect: missing or wrong URL and keys in the iOS build.
    • ATS blocks non-HTTPS: iOS refuses cleartext or non-TLS connections.
    • localhost does not work on a device: a dev address fails off your machine.

    What does "Error initializing database" mean?

    That the code which sets up your database connection threw an error before the app could use it. Whether your Bolt app uses a hosted backend like Supabase or Firebase or a local store, the initialization step creates the client with a configuration and opens the connection, and this error means that step failed. On iOS specifically, it tends to appear when something that was fine in the web preview is different in the native build: the configuration did not travel into the iOS bundle, the network layer is stricter, or the startup timing changed. So the message is pointing at setup and connection, which is where you should look, rather than at your queries or your data.

    What are the common causes on iOS?

    A handful of issues account for most of these. The table lists them with the fix.

    CauseWhy it happens on iOSFix
    Missing or wrong configThe DB URL or key did not make it into the iOS buildConfirm the values are set for the iOS build
    App Transport Security blockiOS refuses a non-HTTPS or non-TLS endpointUse an HTTPS endpoint with a valid certificate
    Pointing at localhostA dev address is unreachable from a deviceUse a real, reachable host, not localhost
    Initialization raceA query runs before the client is readyAwait initialization before the first call
    Native module not linkedA local database module is not built into the appEnsure the native dependency is properly installed

    The most frequent are the first three: a configuration that did not reach the iOS build, an endpoint that App Transport Security blocks because it is not HTTPS, and a leftover localhost address that worked in the browser but cannot be reached from a device.

    How do you fix it?

    Check the suspects in order, starting with configuration. First, confirm the database URL and keys are actually present in the iOS build, since values that exist in your web environment do not automatically reach a native build; verify how your project injects them. Second, make sure the endpoint is HTTPS with a valid certificate, because App Transport Security will block a cleartext or non-TLS connection and surface it as an init failure. Third, replace any localhost or 127.0.0.1 address with a host the device can actually reach. Fourth, ensure your code awaits the database initialization before making the first query, so a race does not throw on startup. If you use a local database module, confirm the native dependency is installed and built into the app. Each check is quick, and one of them is usually the cause.

    What to watch out for

    The first trap is debugging your queries when the error is in setup and connection, so focus on configuration and the network first. The second is assuming the web preview proves the iOS build is configured, when env values and ATS rules differ on a device. The third is leaving a development localhost endpoint in the build. A pre-submission scan such as PTKD.com (https://ptkd.com) reads the compiled APK, AAB, or IPA against OWASP MASVS and surfaces the network endpoints and any cleartext or localhost addresses in your build, which helps you spot a misconfigured or non-HTTPS database endpoint that both breaks initialization and is a security problem. Fixing the config and endpoint is the resolution.

    What to take away

    • "Error initializing database" means the database client failed to start, usually from configuration, network, or startup-order issues on iOS.
    • The top causes are a config missing from the iOS build, an endpoint blocked by App Transport Security, a leftover localhost address, or a query running before initialization finishes.
    • Confirm the URL and keys reach the iOS build, use an HTTPS endpoint, replace localhost with a reachable host, and await initialization before the first query.
    • Use a pre-submission scan such as PTKD.com to surface non-HTTPS or localhost endpoints in your build, which both break initialization and signal a security issue.
    • #bolt-new
    • #database-error
    • #app-transport-security
    • #ios
    • #configuration
    • #ai-coded-apps
    • #troubleshooting

    Frequently asked questions

    What does 'Error initializing database' mean in a Bolt.new app?
    It means the code that sets up your database connection failed before the app could use it. Whether the app uses Supabase, Firebase, or a local store, initialization creates the client and opens the connection, and this error means that step failed. On iOS it usually appears because something that worked in the web preview differs in the native build, such as missing configuration, stricter network rules, or changed startup timing. So look at setup and connection, not your queries.
    Why does my Bolt.new database work in preview but not on iOS?
    Because the web preview and a native iOS build differ in configuration and network rules. The database URL and keys that exist in your web environment may not reach the iOS build, App Transport Security on iOS blocks non-HTTPS connections that a browser tolerated, and a localhost address that worked on your machine is unreachable from a device. So a preview that connects fine does not prove the iOS build is configured, which is why the error shows up only on device.
    How does App Transport Security cause this error?
    App Transport Security makes iOS refuse connections that are not HTTPS with a valid certificate, so if your database endpoint is cleartext HTTP or a non-TLS address, iOS blocks the connection and the client fails to initialize. The fix is to use an HTTPS endpoint with a valid certificate. This is also why a localhost or local-IP development endpoint often fails on a device, since it is typically not served over valid HTTPS.
    How do I fix the database initialization error?
    Work the suspects in order. Confirm the database URL and keys are actually present in the iOS build, since web env values do not automatically reach a native build. Ensure the endpoint is HTTPS with a valid certificate so App Transport Security allows it. Replace any localhost or 127.0.0.1 address with a reachable host. Make sure your code awaits initialization before the first query, and confirm any local database native module is installed and built in.
    Can a scan help with this error?
    Indirectly, by revealing the network configuration. A pre-submission scan such as PTKD.com reads the compiled APK, AAB, or IPA against OWASP MASVS and surfaces the network endpoints and any cleartext or localhost addresses in your build. That helps you spot a misconfigured or non-HTTPS database endpoint, which both breaks initialization under App Transport Security and is a security problem. Seeing the actual endpoint in the binary points you straight at the configuration to fix.

    Keep reading

    Scan your app in minutes

    Upload an APK, AAB, or IPA. PTKD returns an OWASP-aligned report with copy-paste fixes.

    Try PTKD free