Connecting PostgreSQL or MongoDB to n8n on Windows 11 when they're not on the same network

I’m encountering network connectivity issues while trying to connect PostgreSQL or MongoDB databases installed on my Windows 11 machine to n8n running in Docker containers. I’m using Docker and have attempted various connection methods, but neither database is able to establish a connection with the Docker environment.

Environment:

  • Operating System: Windows 11
  • Docker Version: latest
  • PostgreSQL Version: latest
  • MongoDB Version: latest
  • n8n Version: latest

Troubleshooting Steps Taken:

  1. Verified that the Docker containers are running in bridge mode.
  2. Attempted connecting to the databases using their IP addresses and hostnames.
  3. Reviewed firewall settings to ensure they’re not blocking communication between the databases and Docker containers.

Expected Behavior:

PostgreSQL and MongoDB should be able to communicate with n8n running in Docker containers on localhost.

Actual Behavior:

PostgreSQL and MongoDB are unable to communicate with n8n running in Docker containers.

Questions:

  1. Are there any known compatibility issues between PostgreSQL, MongoDB, n8n, and Docker on Windows 11?
  2. Are there specific configuration settings or network configurations that need to be considered?
  3. Is there a recommended approach for connecting databases installed on the Windows environment to n8n running in Docker containers when they’re not on the same network?