# The tables are not created when I am trying to use the postgres as alternate database. The n8n is self hosted. The database.sqlite gets created which shows the switch is not happening

**URL:** <https://community.n8n.io/t/the-tables-are-not-created-when-i-am-trying-to-use-the-postgres-as-alternate-database-the-n8n-is-self-hosted-the-database-sqlite-gets-created-which-shows-the-switch-is-not-happening/59206>\
**Category:** Questions\
**Tags:** postgres\
**Created:** [October 20, 2024, 7:50pm UTC](https://community.n8n.io/t/the-tables-are-not-created-when-i-am-trying-to-use-the-postgres-as-alternate-database-the-n8n-is-self-hosted-the-database-sqlite-gets-created-which-shows-the-switch-is-not-happening/59206 "2024-10-20T19:50:36Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![iShop\_Aravind](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/ishop_aravind/32/46895_2.png) [@iShop\_Aravind](https://community.n8n.io/u/iShop_Aravind)\
**Post date:** [October 20, 2024, 7:50pm UTC](https://community.n8n.io/t/the-tables-are-not-created-when-i-am-trying-to-use-the-postgres-as-alternate-database-the-n8n-is-self-hosted-the-database-sqlite-gets-created-which-shows-the-switch-is-not-happening/59206/1 "2024-10-20T19:50:37Z")

</div>

## Describe the problem/error/question

When I try to use Postgres as an alternate database, the tables are not created. The n8n is self-hosted. The database.sqlite @ /home/node/.n8n gets created, which shows that the switch is not happening. The logs are also not showing any evident of using postgres. Am I missing anything to achieve switch

environment used in the docker-compose file:  
- DB\_PROTOCOL=postgresdb  
- DB\_POSTGRESDB\_HOST=postgres  
- DB\_POSTGRESDB\_PORT=5432  
- DB\_POSTGRESDB\_DATABASE=postgres  
- DB\_POSTGRESDB\_USER=admin  
- DB\_POSTGRESDB\_PASSWORD=admin  
- DB\_POSTGRESDB\_SCHEMA=n8n  
- N8N\_LOG\_LEVEL=debug

## What is the error message (if any)?

No error messages

## Please share your workflow

Not applicable

## Share the output returned by the last node

## Information on your n8n setup

- **n8n version: 1.63.4**
- **Database (default: SQLite):**
- **n8n EXECUTIONS\_PROCESS setting (default: own, main):**
- **Running n8n via (Docker, npm, n8n cloud, desktop app):Docker**
- **Operating system:Linux**

---

<div class="post-metadata">

**Author:** ![TomSpidge](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/tomspidge/32/24404_2.png) [@TomSpidge](https://community.n8n.io/u/TomSpidge)\
**Post date:** [October 21, 2024, 8:11am UTC](https://community.n8n.io/t/the-tables-are-not-created-when-i-am-trying-to-use-the-postgres-as-alternate-database-the-n8n-is-self-hosted-the-database-sqlite-gets-created-which-shows-the-switch-is-not-happening/59206/2 "2024-10-21T08:11:06Z")

</div>

I think your first line should be DB\_TYPE. I also don’t have a SCHEMA line, but that’s probably not vital

My docker compose lines (which work):  
- DB\_TYPE=postgresdb  
- DB\_POSTGRESDB\_HOST=postgres  
- DB\_POSTGRESDB\_PORT=5432  
- DB\_POSTGRESDB\_DATABASE=${POSTGRES\_DB}  
- DB\_POSTGRESDB\_USER=${POSTGRES\_NON\_ROOT\_USER}  
- DB\_POSTGRESDB\_PASSWORD=${POSTGRES\_NON\_ROOT\_PASSWORD}

---

<div class="post-metadata">

**Author:** ![barn4k](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/barn4k/32/8170_2.png) [@barn4k](https://community.n8n.io/u/barn4k)\
**Post date:** [October 21, 2024, 9:21am UTC](https://community.n8n.io/t/the-tables-are-not-created-when-i-am-trying-to-use-the-postgres-as-alternate-database-the-n8n-is-self-hosted-the-database-sqlite-gets-created-which-shows-the-switch-is-not-happening/59206/3 "2024-10-21T09:21:42Z")

</div>

yep, **DB\_TYPE** should be used. There is no DB\_PROTOCOL env

[Database environment variables | n8n Docs](https://docs.n8n.io/hosting/configuration/environment-variables/database/)

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/system/32/195824_2.png) [@system](https://community.n8n.io/u/system)\
**Post date:** [January 19, 2025, 9:22am UTC](https://community.n8n.io/t/the-tables-are-not-created-when-i-am-trying-to-use-the-postgres-as-alternate-database-the-n8n-is-self-hosted-the-database-sqlite-gets-created-which-shows-the-switch-is-not-happening/59206/4 "2025-01-19T09:22:27Z")

</div>

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