# Npx directus-template-cli@latest init failed due to confliction of postgres port

**URL:** <https://community.directus.com/t/npx-directus-template-cli-latest-init-failed-due-to-confliction-of-postgres-port/1124>\
**Category:** Help\
**Tags:** hosting\
**Created:** [September 5, 2025, 3:24pm UTC](https://community.directus.com/t/npx-directus-template-cli-latest-init-failed-due-to-confliction-of-postgres-port/1124 "2025-09-05T15:24:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yuhu\_Jia](https://sea2.discourse-cdn.com/flex002/user_avatar/community.directus.com/yuhu_jia/32/870_2.png) [@Yuhu\_Jia](https://community.directus.com/u/Yuhu_Jia)\
**Post date:** [September 5, 2025, 3:24pm UTC](https://community.directus.com/t/npx-directus-template-cli-latest-init-failed-due-to-confliction-of-postgres-port/1124/1 "2025-09-05T15:24:30Z")

</div>

![image](https://us1.discourse-cdn.com/flex002/uploads/directus/original/1X/1da04b7ce4f8eb552a237a1872c994521095940e.png)

---

<div class="post-metadata">

**Author:** ![bryantgillespie](https://sea2.discourse-cdn.com/flex002/user_avatar/community.directus.com/bryantgillespie/32/33_2.png) [@bryantgillespie](https://community.directus.com/u/bryantgillespie)\
**Post date:** [September 9, 2025, 2:41pm UTC](https://community.directus.com/t/npx-directus-template-cli-latest-init-failed-due-to-confliction-of-postgres-port/1124/2 "2025-09-09T14:41:49Z")

</div>

Hey there! 👋

Welcome to the Directus community!

Looks like you’re running into a port conflict with PostgreSQL. This usually happens when you already have another Directus project (or any other service) running on the same port.

## Quick fixes

**Option 1: Stop your existing project**

- If you have another Directus project running, just `Ctrl+C` to stop it

- Or check what’s running on port 5432:

```bash

# Check what’s using the PostgreSQL port

lsof -i :5432

```

**Option 2: Change the port mapping**

- Open your `docker-compose.yml` file

- Find the PostgreSQL service section

- Change the port mapping from `5432:5432` to something like `5433:5432`

- This maps your local port 5433 to the container’s port 5432

Example:

```auto
services:
  database:
    ports:
    - "5433:5432" # Changed from 5432:5432

```

Then just start it up with the new port mapping and you should be good to go!

You can also use the `npx directus-template-cli@latest apply` command to apply the backend template to an existing Directus instance - instead of rerunning `init`.

---

<div class="post-metadata">

**Author:** ![Yuhu\_Jia](https://sea2.discourse-cdn.com/flex002/user_avatar/community.directus.com/yuhu_jia/32/870_2.png) [@Yuhu\_Jia](https://community.directus.com/u/Yuhu_Jia)\
**Post date:** [September 17, 2025, 3:43pm UTC](https://community.directus.com/t/npx-directus-template-cli-latest-init-failed-due-to-confliction-of-postgres-port/1124/3 "2025-09-17T15:43:32Z")

</div>

Hi Bryan,

Thank you for the detailed and very useful reply, the issue was solved now.

But here is a another question, why there is no more recommendation about initializing a new project with “npm init directus-project my-project“ in the document?
