Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

725
Views
NGINX net::ERR_CONNECTION_REFUSED con PM2 ReactJS Frontend y Express Backend en un AWS

Tengo ejecutando en un servidor web de Amazon una interfaz ReactJS que se conecta a un Express APIREST. Con PM2 para lanzar ambos procesos y NGINX.

El problema surge cuando trato de iniciar sesión en la aplicación en Chrome, la interfaz está bien pero se niega a conectarse a APIREST. Imagen de error

Estos son los archivos que tengo:

APIREST .env

 DB_CCT=my_db DB_CCT_USER=user DB_CCT_PASS=password DB_CCT_HOST=127.0.0.1 NODE_ENV=development PORT=8017 JWT_SECRET=jotauvedoblete

FRONTEND ReactJS .env

También intenté agregar la IP pública en lugar de localhost o 127.0.0.1 pero tampoco funciona, muestra que se agotó el tiempo de conexión.

 REACT_APP_DB=http://localhost:8017/api/v1/

PM2 ecosistema.config.js

 module.exports = { apps: [{ name: 'CCT_REACT', cwd: 'cct-web-client/', script: 'npm', // Options reference: https://pm2.io/doc/en/runtime/reference/ecosystem-file/ args: 'run start:production', instances: 1, autorestart: true, watch: false, max_memory_restart: '1G', env: { NODE_ENV: 'production', PORT: 5001 }, env_production: { NODE_ENV: 'production', PORT: 5001 } }, { name: 'CCT_API_REST', cwd: 'cct_api_rest/', script: 'npm', // Options reference: https://pm2.io/doc/en/runtime/reference/ecosystem-file/ args: 'run start', instances: 1, autorestart: true, watch: false, max_memory_restart: '1G', env: { NODE_ENV: 'production', PORT: 8017 }, env_production: { NODE_ENV: 'production', PORT: 8017 } }], deploy: { production: { } } }

Servicio NGINX

 server { listen 80 default_server; listen [::]:80 default_server; root /home/ubuntu/CCT/cct-web-client/build; index index.html index.htm index.nginx-debian.html; server_name _; location / { try_files $uri/ /index.html?q=$uri&$args; } }
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Si se rechaza una conexión, significa que las solicitudes se bloquean.

Veo que ha especificado el PUERTO 8017 para su aplicación API, verifique 2 cosas:

  1. Verifique en sus grupos de seguridad de AWS de las reglas de entrada de EC2 para que el PUERTO 8017 esté abierto para todos.
  2. También intente reiniciar Nginx una vez: `sudo systemctl restart Nginx.
  3. Para su API, simplemente inicie su API sin pm2 y agregue una consola. Inicie sesión en su ruta y middleware y realice una solicitud POST de POSTMAN para verificar si su aplicación funciona correctamente.
about 4 years ago · Juan Pablo Isaza Report

0

Permita conectarse al puerto 80 en su aws y elimine todos los demás y use la siguiente configuración de nginx. También configure la URL de backend de api en su interfaz para su dominio o ip en el puerto 80.

 server { listen 80 default_server; listen [::]:80 default_server; root /home/ubuntu/CCT/cct-web-client/build; index index.html index.htm index.nginx-debian.html; server_name _; # Frontend location / { try_files $uri /index.html; } # node api reverse proxy location /api/ { proxy_pass http://localhost:8017/; }

}

También asegúrese de verificar primero con cualquier cliente de API si puede consumir su API sin interfaz. No debe ser tiempo de espera.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!