Unable to connect to Heroku Postgres in 0.104.0+

Hey all. I’m having issues with recent versions of n8n.

I initially deployed to Heroku with this configuration which worked great, but used a slightly outdated version missing some features (Thanks @jan for the help on the other thread!). When I upgraded from 0.98.0 to 0.104.0 I to access those features I started getting an error connecting to the hosting DB.

There was an error initializing DB: no pg_hba.conf entry for host "x", user "y", database "z", SSL off

I believe this is because Heroku Postgres databases require you to connect with SSL and it’s saying that it isn’t connecting to the database with SSL.

Unfortunately Heroku doesn’t give access to the CA files to use SSL with Postgres. I think it’s just a matter of connecting with the sslmode=require parameter Heroku mentions here. This worked in the previous version without issue. Any thoughts as to what might be happening here?

Can you please upgrade to the latest n8n version 0.110.3 and see if you get the same problem here. I do not think that we changed anything there internally. Maybe something in an underlying library did or there was some kind of bug. So would be interesting to know if the problem is still there or not.

Hey Jan - same issue with 0.110.3. Here’s my Dockerfile:

FROM node:lts-alpine

# pass N8N_VERSION Argument while building or use default
ARG N8N_VERSION=0.110.3

# Update everything and install needed dependencies
RUN apk add --update graphicsmagick tzdata

# Set a custom user to not have n8n run as root
USER root

# Install n8n and the also temporary all the packages
# it needs to build it correctly.
RUN apk --update add --virtual build-dependencies python build-base && \
	npm_config_user=root npm install -g n8n@${N8N_VERSION} && \
	apk del build-dependencies

# Specifying work directory
WORKDIR /data

# copy start script to container
COPY ./start.sh /

# make the script executable
RUN chmod +x /start.sh

# define execution entrypoint
CMD ["/start.sh"]

And for context, start.sh exports the following variables which I think should be valid for n8n to connect:

  • DB_TYPE (postgresdb)
  • DB_POSTGRESDB_HOST (this one and the following are obtained by parsing a connection string from an environment variable; I double checked to make sure they’re all parsed out correctly)
  • DB_POSTGRESDB_PORT
  • DB_POSTGRESDB_DATABASE
  • DB_POSTGRESDB_USER
  • DB_POSTGRESDB_PASSWORD

Was able to get this working by adding the Heroku environment variable: heroku config:set PGSSLMODE=no-verify - all set here.