When running two NodeJs apps in same vps one use others .env conf and get connected to the wrong db

Viewed 19

I have a VPS with Instance (Debian 9.4 (stretch) 20180404)

There I have a few WordPress sites and also a nodejs app that I will call "prod" running with PM2 without any problem whit apache2.

Now I want to run a new nodejs app on a subdomain which basically will be the dev environment of the previous and working node.

My issue is that when I start dev, prod gets connected to dev's database, no matter if I run dev as "node inde.js" or by PM2.

Each node environment is in its correct web folder and has a specific .env that has the credentials to access each database (one for prod and another for dev)

Could anybody please help me to sort out this issue?

On the apache2 config, I configure a proxypass reverse so I don't have to add the:3000 and I copied the conf to dev, could be that a problem? Are both listening to the same port? if yes, how do you suggest solving it?

Thanks in advance!

1 Answers

I resolved it.

I leave the solution in case anybody comes to the same issue.

The problem was indeed the port, so I'm using port 3000 for production and port 3002 for dev.

Also with the .env files, I decided to have one .env file for each environment and both are in the same location outside the git repository.

Everything works as expected.

Cheers!

Related