Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] When deploying on AWS I get error Error: connect ECONNREFUSED 127.0.0.1:5432 #669

Open
juancarlosv2711 opened this issue Nov 21, 2024 · 3 comments
Assignees

Comments

@juancarlosv2711
Copy link

It seems that at the deploymoment, the instance is trying to connect to postgres locally (127.0.0.1) instead of rds set up.

I have followed documentation here

An i have also created the /var/www/html/current/config/default.json path

The file looks something like this

{
"db": {
"name": "my_evershop",
"user": "evershop",
"password": "evershop",
"host": "endpoint.rds.amazonaws.com",
"port": 5432
},
"env": {
"NODE_ENV": "production", // Set environment to 'production' or 'development' as needed
"PORT": 3000 // Define the port the application should run on
},
"log": {
"level": "info", // The logging level (info, debug, error, etc.)
"path": "/var/www/html/logs" // Path where logs will be saved
},
"api": {
"endpoint": "https://api.example.com" // Define any API endpoints the app may interact with
}
}

This is the error I get after runnning pm2 start npm -- start (bash script)

`/home/ubuntu/.pm2/logs/npm-out.log last 15 lines:
0|npm | address: '127.0.0.1',
0|npm | port: 5432
0|npm | }
0|npm |
0|npm | > start
0|npm | > evershop start
0|npm |
0|npm | Error: connect ECONNREFUSED 127.0.0.1:5432
0|npm | at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1549:16) {
0|npm | errno: -111,
0|npm | code: 'ECONNREFUSED',
0|npm | syscall: 'connect',
0|npm | address: '127.0.0.1',
0|npm | port: 5432
0|npm | }

/home/ubuntu/.pm2/logs/npm-error.log last 15 lines:
0|npm | npm ERR! enoent This is related to npm not being able to find a file.
0|npm | npm ERR! enoent
0|npm |
0|npm | npm ERR! A complete log of this run can be found in:
0|npm | npm ERR! /home/ubuntu/.npm/_logs/2024-11-21T00_02_26_682Z-debug-0.log
0|npm | npm ERR! code ENOENT
0|npm | npm ERR! syscall open
0|npm | npm ERR! path /var/www/html/package.json
0|npm | npm ERR! errno -2
0|npm | npm ERR! enoent ENOENT: no such file or directory, open '/var/www/html/package.json'
0|npm | npm ERR! enoent This is related to npm not being able to find a file.
0|npm | npm ERR! enoent
0|npm |
0|npm | npm ERR! A complete log of this run can be found in:
0|npm | npm ERR! /home/ubuntu/.npm/_logs/2024-11-21T00_02_27_205Z-debug-0.log

`

@foundanand
Copy link

The app is attempting to connect to PostgreSQL on 127.0.0.1 (localhost) instead of your RDS instance. This is likely because the database connection details in your default.json configuration file aren't being properly loaded, or the app is hardcoded to connect to localhost

Try this telnet endpoint.rds.amazonaws.com 5432 and tell what response do you get

@treoden
Copy link
Collaborator

treoden commented Nov 27, 2024

Hi @juancarlosv2711 ,

The database configuration should be in the environment variables( I can see the docs is outdated and will update it soon.).
Can you follow this: https://evershop.io/docs/development/deployment/deploy-evershop-to-azure#step-5-configure-environment-variables

Thanks

@treoden treoden assigned juancarlosv2711 and unassigned treoden Nov 28, 2024
@juancarlosv2711
Copy link
Author

Hi @juancarlosv2711 ,

The database configuration should be in the environment variables( I can see the docs is outdated and will update it soon.). Can you follow this: https://evershop.io/docs/development/deployment/deploy-evershop-to-azure#step-5-configure-environment-variables

Thanks

Thank you for your response! I noticed that the link provided points to the Azure deployment guide. However, I am deploying the Evershop application on AWS. Could you please confirm if setting up environment variables is still necessary in this context? If so, are there specific guidelines for AWS that I should follow?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants