Windows 10 - can not start n8n with PostgreSql in development mode

I want to run the n8n application in development mode (using npm) and connect to my own PostgreSql. But I can not do this in Windows 10 OS. Below is what I did:

  1. Checkout n8n source code
  2. Update n8n\packages\cli\config\index.ts, changed ‘database.type.default’ to ‘postgresdb’ and updated postgresdb config to my posgresql.
  3. npm run build //ran successfully without any error log
  4. npm run dev //ran successfully without any error log
  5. access to localhost:5678, the message "There was a problem loading init data:**
    **API-Server can not be reached. It is probably down." appeared and blocked to UI (looks like the backend rest API could not start because of some reasons)

Note that this issue does not happen in Mac OS just in Windows 10.

1 Like

Welcome to the community @ThoaiNguyenHuu842!

First, nobody is ever supposed to make changes in the file n8n\packages\cli\config\index.ts.If you want to use Postgres instead of SQLite then you simply set the environment variables as described here:

It looks also like you skiped some setup steps. The full guide on how to set up n8n can be found here:

If you go directly in the packges/cli folder and run npm run start what does happened? Does it output any error messages?

Hi Jan, thank you for your prompt reply. I am aware of the environment variables but what I want is running n8n in development mode locally with my PostgreSql DB, then I will be able to implement so business logic inside n8n source code that need to access to my PostgreSql DB.

I tried to run npm run start in packages/cli but nothing happens (please take a look at the below image)
2020-06-28 21_57_23-Windows PowerShell

If that is more convenient for you that way then I guess it is OK as long as you are aware of what you are doing.

That nothing happens at all is strange. Sadly have no idea why it would not work for you. Did you try to run npm run build again? If it then does still not work, I would advice you to start again from the beginning and follow the guide step by step and see if it works then. Maybe you missed one step. Would also only make the changes in the source code once it works fine with SQLite. If that works and it stops worked afterward, you know at least that the changes were the problem.

Still nothing happens, It looks like there is an issue in Window 10 that prevents n8n backend connects to PostgreSQL and make the backend crash.
Do we have anyway to see the log file in n8n backend?

So if you say that the problem has to do with Postgres it means it works fine with SQLite?

There are no specific n8n-log files. So in this case you really would have to go into the n8n code and start debugging to see where it crashes exactly and for what reason.

Yes, it works fine with SQLite (our default storage), let me investigate more, I will update to you if having any news. Thank for your support.