Connection for postgres chat memory to supabase in docker should work like supabase vector store

I am trying to get the AI node to use supabase as postgres chat memory. I have done a lot of searching, but the closest I got was some replies that said something about not working with ip v4. I don’t really understand but refuse to believe this can’t be resolved. I am trying to see the exact message N8N sends for it’s request so I can see if it is trying the same format that works from the CLI.

I tried many combinations of IP address and port from my cli, and finally hit upon

C:\Users\Owner\Documents\GitHub\AgentSwarm0125\examples>curl -H “apikey:<ANON_KEY from supabase>” “http://localhost:8000/rest/v1/messages

which returned the contents of the table (my table is named messages).

I went on and tried similar combinations in postgres credentials. While every combo with port 5432 failed with a message, with port 8000 only local host failed with similar message.

{ “errno”: -111, “code”: “ECONNREFUSED”, “syscall”: “connect”, “address”: “192.168.65.254”, “port”: 5432 }

Three different addresses, docker network IP, docker container name and host.docker.internal all responded with “Connection terminated unexpectedly” Every time n8n returns “connection terminated” the docker log reports

2025-02-05 20:44:07 2025/02/06 04:44:07 [error] 1118#0: *585923 [kong] access.lua:53 [basic-auth] header has unrecognized format, client: 192.168.90.1, server: kong, request: “GET / HTTP/2.0”, host: “192.168.1.235:8443”

http://host.docker.internal:3000/rest/v1 connects and works with my supabase credential.

I set N8N to debug, and the logs show the request info, but still not the whole request string (so I can see the header format).

2025-02-07 12:27:56 Connection terminated unexpectedly
2025-02-07 12:27:56 Error: Connection terminated unexpectedly
2025-02-07 12:27:56 at /usr/local/lib/node_modules/n8n/node_modules/pg-pool/index.js:45:11
2025-02-07 12:27:56 at processTicksAndRejections (node:internal/process/task_queues:95:5)
2025-02-07 12:27:56 at PostgresChatMessageHistory.ensureTable (/usr/local/lib/node_modules/n8n/node_modules/@langchain/community/dist/stores/message/postgres.cjs:97:13)
2025-02-07 12:27:56 at PostgresChatMessageHistory.getMessages (/usr/local/lib/node_modules/n8n/node_modules/@langchain/community/dist/stores/message/postgres.cjs:119:9)
2025-02-07 12:27:56 at BufferWindowMemory.loadMemoryVariables (/usr/local/lib/node_modules/n8n/node_modules/langchain/dist/memory/buffer_window_memory.cjs:85:26)
2025-02-07 12:27:56 at BufferWindowMemory.callMethodAsync (/usr/local/lib/node_modules/n8n/node_modules/@n8n/n8n-nodes-langchain/dist/utils/logWrapper.js:16:16)
2025-02-07 12:27:56 at Proxy.connectionType (/usr/local/lib/node_modules/n8n/node_modules/@n8n/n8n-nodes-langchain/dist/utils/logWrapper.js:55:43)
2025-02-07 12:27:56 at AgentExecutor._formatValues (/usr/local/lib/node_modules/n8n/node_modules/langchain/dist/chains/base.cjs:131:31)
2025-02-07 12:27:56 at AgentExecutor.invoke (/usr/local/lib/node_modules/n8n/node_modules/langchain/dist/chains/base.cjs:53:28)
2025-02-07 12:27:56 at ExecuteContext.toolsAgentExecute (/usr/local/lib/node_modules/n8n/node_modules/@n8n/n8n-nodes-langchain/dist/nodes/agents/Agent/agents/ToolsAgent/execute.js:185:30)
2025-02-07 12:27:56
2025-02-07 12:27:56 The session “7skwtwjnug” is not registered

There has got to be a combo for the postgres chat memory node and postgres credential that will work.

Information on your n8n setup

  • **n8n version:1.72.1
  • **Database (default: SQLite):supabase in docker
  • **n8n EXECUTIONS_PROCESS setting (default: own, main):Must be default
  • **Running n8n via (Docker, npm, n8n cloud, desktop app):Docker
  • **Operating system:Windows

Making progress. I found out default install on supabase does not expose port 5432 and that is what N8N expects to use. If you change it to 8000 you get Kong which is not compatible. I added ports: 5432:5432 to supabase db container. Then got a password error! Hurray?! I changed the password to POSTGRES_PASSWORD in .env and now I am getting a missing column error. Closer and closer

Changed column names in supabase table messages to message and session_id. It asked me something about pinning it and I said to unpin. Not sure what that meant but I did it and BAM, there is the message!

Of course, that just leads to other issues, but I believe most of them are solvable. When I record messages from other chat tools, I add

  • role of assistant or user,
  • embedding model
  • embedding
  • user_id.
1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.