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

Hey there! :waving_hand:

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:


# 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:

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.

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?