N8N Postgres tables not getting created within Azure App Service

Describe the problem/error/question

I am trying to self-host N8N using Azure App service. It is using the Docker container image and a Postgres DB but the database is not getting populated so the workflows and credentials are not persisting. Below are the environment variables I have setup within the . I have tried quite a few things but i can’t seem to get the database setup.

Information on your n8n setup

  • n8n version: 1.70.
  • Database (default: SQLite): Postgres
  • Running n8n via (Docker, npm, n8n cloud, desktop app): Docker image via App service
  • Operating system: Linux

Hey @Pandapop14

Welcome to the community :raised_hands:

I am not familiar with Azure app service but if the tables are not being created my user assumption would be that the environment variables are not being set correctly.

Are you setting them in the correct location and doing it before n8n starts? Don’t forget you will also need to set the encryption key option if you don’t have any storage that you are keeping.

Do you get any errors in the log when starting n8n with those options? As a quick test you could set WEBHOOK_URL to a random url and see if the webhook url in n8n changes to that value.

Hey @Jon

Thanks for response. So I’m pretty sure the environment variables are in the right place as if I don’t add the DB variables the n8n instance loads and works. I also tried amend the set WEBHOOK_URL as suggested and it got updated correctly.

I’ve looked through the logs and without the DB variables the container loads however once added in I get the following error;

2024-12-10T11:44:35.909Z ERROR - Container didn’t respond to HTTP pings on port: 5678, failing site start.

I’ve cross checked my variables within psql so I think there right so i am a bit stuck at the minute.

Thanks

After a lot of different attempts and debugging I’ve managed to get to the bottom of this, so I am jotting down the solution below in case anyone else ends up in a similar situation.

The core issue why it wasn’t connecting was due to the SSL certification against the PostGres DB. I initially tried pass this through as an environment variable but due to the nature of app service the formatting of the PEM certificate (the line breaks) do not get picked up.

The way around this was to store the file in Azure Storage and setup a path mapping and pass this path through the DB_POSTGRESDB_SSL_CERT_FILE variable.

Hope that help anyone whoever ends up in the same boat and i save you the pain i had endured solving this :sweat_smile:

2 Likes

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