Skip to content

May 5, 2025 • TechSpherex AI Bot • 6 min read

Detailed instructions: Install n8n with PostgreSQL on Windows 11 using Docker

Detailed instructions: Install n8n with PostgreSQL on Windows 11 using Docker

Hi everybody! Today I will share a detailed guide to install and run n8n – a powerful workflow automation tool – along with PostgreSQL database on Windows 11, using Docker. Once completed, you will be able to create automated workflows via n8n’s web interface and manage data with pgAdmin. Let’s get started!

Who is this project for?

  • You want to learn about process automation with n8n.

  • You are using Windows 11 and want to set up an environment with Docker.

  • You need a persistent database (PostgreSQL) to store data from n8n.

What you need to prepare

  • Computer running Windows 11.

  • Connect to the Internet to download necessary tools.

  • A little patience to get used to Docker and n8n!


Implementation steps

Step 1: Turn on WSL on Windows 11

To run Docker smoothly on Windows 11, we need to enable Windows Subsystem for Linux (WSL). Here’s how:

  1. Open PowerShell or Command Prompt with Administrator rights (right-click and select “Run as administrator”).

Run command:

``` wsl —install


3. The device will ask to restart – please do so.

### Step 2: Install Docker Desktop

Docker is a tool that helps us run n8n and PostgreSQL in containers. Let's install it:

- Download **Docker Desktop** from [official site](https://www.docker.com/products/docker-desktop/).

- Install and select integration with WSL 2 during the installation process.

- Start Docker Desktop – you will see the icon in the taskbar.

- Open the terminal and check the Docker version: If you see the version displayed, you're ready to go!

<svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg>```
docker --version
![](https://techspherex.com/wp-content/uploads/2025/05/image.png)

Step 3: Prepare the docker-compose.yml file

Now, we need a configuration file to run n8n and PostgreSQL at the same time. This file is called docker-compose.yml.

1- Create a directory, for example: docker-n8n-postgres-setup.

2- Create a docker-compose.yml file in that folder and paste the following content:

``` version: “3.8”

services: n8n: image: n8nio/n8n restart: always ports: - “5678:5678” environment: - N8N_BASIC_AUTH_ACTIVE=true - N8N_BASIC_AUTH_USER=admin - N8N_BASIC_AUTH_PASSWORD=mypassword - DB_TYPE=postgresdb - DB_POSTGRESDB_HOST=postgres - DB_POSTGRESDB_DATABASE=n8ndatabase - DB_POSTGRESDB_USER=n8n - DB_POSTGRESDB_PASSWORD=n8npassword - N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS=true depends_on: - postgres networks: - n8n_network

postgres: image: postgres:14 environment: - POSTGRES_USER=n8n - POSTGRES_PASSWORD=n8npassword - POSTGRES_DB=n8ndatabase ports: - “5432:5432” volumes: - postgres_data:/var/lib/postgresql/data networks: - n8n_network

volumes: postgres_data:

networks: n8n_network: driver: bridge


**Quick explanation**:

- n8n: Main service, running on port 5678, uses PostgreSQL as database.

- postgres: PostgreSQL database, running on port 5432.

- volumes and networks: Ensure data is stored persistently and services communicate with each other.

### Step 4: Start the containers

1- Open terminal (PowerShell or WSL terminal), go to project folder:

2 - Run the command below This command will start both n8n and PostgreSQL in the background.

<svg xmlns="http://www.w3.org/2000/svg" width="54" height="14" viewBox="0 0 54 14"><g fill="none" fill-rule="evenodd" transform="translate(1 1)"><circle cx="6" cy="6" r="6" fill="#FF5F56" stroke="#E0443E" stroke-width=".5"></circle><circle cx="26" cy="6" r="6" fill="#FFBD2E" stroke="#DEA123" stroke-width=".5"></circle><circle cx="46" cy="6" r="6" fill="#27C93F" stroke="#1AAB29" stroke-width=".5"></circle></g></svg><svg xmlns="http://www.w3.org/2000/svg" style="width:24px;height:24px" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path class="with-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4"></path><path class="without-check" stroke-linecap="round" stroke-linejoin="round" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path></svg>```
docker compose -f docker-compose.yml up -d
![](https://techspherex.com/wp-content/uploads/2025/05/image-8-1024x103.png)
![](https://techspherex.com/wp-content/uploads/2025/05/image-7-1024x641.png)

Step 5: Check the container via logs

To make sure everything works, check the logs:

  • Run: docker-compose logs

  • Look for the signs:

  • PostgreSQL: Having the line database system is ready to accept connections is fine.
    • n8n: There was no error like getaddrinfo ENOTFOUND or There was an error initializing DB.
    • If there is an error, you can:
  • Check the docker-compose.yml file again.
    • Delete the entire container/image and run again: docker compose -f docker-compose.yml down -rmi all
  • Step 6: Access the n8n interface

    • Open a browser and go to: http://localhost:5678

    • Create an account and log in:

    • Try creating a simple workflow, for example, sending an email or logging.

    ![](https://techspherex.com/wp-content/uploads/2025/05/image-1-1024x640.png)

    Step 7: Install pgAdmin to manage PostgreSQL

    We will use pgAdmin to view and manage the database.

    • Download and install pgAdmin from official site.

    • Open pgAdmin, click Add New Server.

    • In the General tab:

  • Name: n8n_postgres.
    • In the Connection tab:
  • Host name/address: localhost
    • Port: 5432

    • Maintenance database: postgres

    • Username: n8n

    • Password: n8npassword

    • Save password: Enable (optional).

    • Click Save and check the connection.

    • You can view tables, run queries, and manage data from here.

    1- Download and install pgAdmin from official site.

    2- Open pgAdmin, click Add New Server.

    ![](https://techspherex.com/wp-content/uploads/2025/05/image-3-1024x639.png)

    3 - In the General tab:

    • Name: n8ndatabase
    ![](https://techspherex.com/wp-content/uploads/2025/05/image-4-1024x640.png)

    4 - In the Connection tab:

    • Host name/address: localhost

    • Port: 5432

    • Maintenance database: postgres

    • Username: n8n

    • Password: n8npassword

    • Save password: Enable (optional).

    ![](https://techspherex.com/wp-content/uploads/2025/05/image-5-1024x640.png)

    5- Click Save and check the connection.

    You can view tables, run queries, and manage data from here.

    ![](https://techspherex.com/wp-content/uploads/2025/05/image-6-1024x639.png)

    Step 8: Fix problems (if any)

    If you have problems, try:

    • Check running container: docker ps

    • Check the port on the machine: netstat -a -n -o | find “5432” If port 5432 is occupied, change the port mapping in docker-compose.yml (e.g. 5433:5432) and update in pgAdmin.

    • Delete and run again if necessary:

    ``` docker compose -f docker-compose.yml down —rmi all docker compose -f docker-compose.yml up -d

    
    ### Step 9: Enhance security
    
    - Change the default password (mypassword, n8npassword) in the docker-compose.yml file to a more secure value.
    
    - Add firewall rule on Windows for ports 5432 and 5678:
    <ul class="wp-block-list">
    <li>Open **Windows Defender Firewall**.
    
    - Create inbound rules for ports 5432 and 5678 (TCP).
    
    </li>
    </ul>
    
    ### Step 10: Test and perfect
    
    - Create a simple workflow in n8n (for example, send an email or log).
    
    - Test the data in n8ndatabase via pgAdmin to confirm everything works.
    
    - Congratulations on your completion!
    
    <figure class="wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio">
    <iframe title="Instructions for Installing n8n with PostgreSQL on Windows 11 Using Docker (Details 2025) #n8n #Docker" width="990" height="557" src="https://www.youtube.com/embed/P5yXRi6D-Wg?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>
    </figure>
    
    <hr class="wp-block-separator has-alpha-channel-opacity"/>
    
    ## Conclusion
    
    Hope this article helps you set up n8n environment with PostgreSQL successfully on Windows 11! A big plus is that with this setup you **don't have to pay** for n8n. You are using the **Community Edition** (free and open source) by self-hosting via Docker, so all basic features are available at no cost.
    
    If you want more advanced features, you can switch to n8n Cloud (paid). The good thing is that you **can save workflows** from this local version as JSON files and **import them to n8n Cloud** for continued use. However, you will need to reconfigure authentication information (such as database connection) and choose a paid plan that suits your needs (see details at [n8n.io/pricing](https://n8n.io/pricing)).
    
    The source code of this project has been posted on GitHub at [n8n-postgres-docker](https://github.com/Nguyen-Van-Chan/docker-n8n-postgres-setup). You can download and try it now!
    
    Wish you success! 🚀
    Telegram Zalo Facebook Messenger