I'm relatively new to app deployments and I'm currently trying to deploy a Nest.js app, but it simply will not run on host 0.0.0.0. This is causing problems when I try to dockerize the app and when I try to deploy it using Railway. I just get this error over and over again:
[Nest] 32 - 12/18/2022, 6:32:50 PM ERROR [TypeOrmModule] Unable to connect to the database. Retrying (6)... Error: connect ECONNREFUSED 127.0.0.1:5432
Railway in particular tells me that my application is listening on 127.0.0.1 instead of 0.0.0.0, which they require in order to run it.
I've changed the environment variables in both Railway and my .env file, I've manually set it using app.listen(9999, '0.0.0.0')
in my main.ts file, and I've tried running the app with npm run start:dev --host 0.0.0.0
. I've checked my firewalls to make sure that node.exe and NodeJS javascript runtime are allowed through. I've even tried editing my hosts file to get it to point somewhere else, but no luck. The URL the app runs on always ends up being 127.0.0.1:9999. Running the app on any other server isn't an issue though, as trying with other local/network IP addresses turns out fine, but it looks like there's just an issue with 0.0.0.0.
Does anyone know what could be the problem here?