Self-host n8n on Ubuntu 24.04 with Docker Compose, PostgreSQL and HTTPS

Hi everyone!

I wanted to share a practical guide for self-hosting n8n on an Ubuntu 24.04 VPS with Docker Compose and PostgreSQL.

The walkthrough focuses on a few things that matter when moving beyond a basic installation:

  • Running n8n and PostgreSQL in separate containers with persistent volumes.

  • Binding n8n to 127.0.0.1:5678 rather than exposing its application port publicly.

  • Configuring Nginx, HTTPS and reverse-proxy settings for correct webhook URLs.

  • Protecting database credentials and the n8n encryption key.

  • Backing up PostgreSQL and n8n data, including an isolated database restore check.

  • Using version-pinned container images and a controlled update process.

The full guide includes Docker Compose configuration, shell commands, verification steps and troubleshooting notes:

Disclosure: I’m a co-founder at Raff Technologies. We use a Raff Ubuntu VM in the guide, but the Docker Compose setup is applicable to other Ubuntu VPS providers as well.

I hope this is useful for anyone managing their own n8n instance. Feedback and suggestions are welcome!

1 Like