Replit failed to deploy (Autoscale, flask app)

My app failes to deploy with autoscale because of keyerror

Here is the logs:

2024-03-19T12:31:41Z info: Deployment: 523b29d6-538d-4cd4-9a61-db8472680b8e
2024-03-19T12:31:41Z info: Build: 46726384-5855-4c3e-a9e7-7014b71369cf
2024-03-19T12:31:41Z info: Connecting to builder
2024-03-19T12:31:42Z info: Builder connected
2024-03-19T12:31:42Z info: Installing packages
2024-03-19T12:31:42Z info: Skipping Build as no Build command set
2024-03-19T12:31:43Z info: Pushing pid1 binary layer...
2024-03-19T12:31:44Z info: Created pid1 binary layer
2024-03-19T12:31:45Z info: Skipping Python layer creation
2024-03-19T12:31:45Z info: Skipping Node layer creation
2024-03-19T12:31:45Z info: Pushing Repl layer...
2024-03-19T12:31:45Z info: Pushing hosting layer...
2024-03-19T12:31:45Z info: Retrieved cached nix layer
2024-03-19T12:31:46Z info: Created hosting layer
2024-03-19T12:31:48Z info: Created Repl layer
2024-03-19T12:31:48Z info: Pushing Repl (cache) layer...
2024-03-19T12:31:48Z info: Pushing Repl (cache) layer...
2024-03-19T12:31:49Z info: Created Repl (cache) layer
2024-03-19T12:31:50Z info: Pushed image manifest
2024-03-19T12:31:50Z info: Pushed soci index manifest
2024-03-19T12:31:50Z info: Pushed referrer manifest
2024-03-19T12:31:57Z info: Creating Autoscale service
  File "/nix/store/8w6mm5q1n7i7cs1933im5vkbgvjlglfn-python3-3.10.13/lib/python3.10/", line 680, in __getitem__
KeyError: 'APP_KEY'
2024-03-19T12:32:15Z error: The deployment failed to initialize due to a configuration or code error. Check the logs tab for more information. For additional support, please post on and a staff member will take a look.

I have tried to run it before deploying, changing the port, basically any method i could find, but no luck. It also says my secret is out of sync.

Make sure you sync your secrets to the deployment, that seems to be the error cause here.

1 Like

How do you sync the secret?

When deploying, add a deployment secret, with the same name and value as your repl’s one.