Direct connect to the Discourse Database


I am looking for some custom aggregates and stats. I have seen the Postgres schema tables, I can get what I want using joins and queries. I am using NodeJS to connect to Postgres. Also, this server is different than my discourse server.
I need to how can I allow the Postgres port to be opened for my server to allow connection and fetch the data.


That’s almost certainly a bad idea. The answer is sort of “if you don’t know how, then you probably shouldn’t,” but there is an expose section in app.yml that you can modify. But then you’ll need to figure out how to do something about controlling access.

Have you considered the Data Explorer Plugin? It’s safe, easy, and you can find plenty of examples.