I'm trying to get my express/ node application deployed to my AWS EC2 although I'm having troubles. I can run it locally but when I ssh onto the EC2 machine and run the following command I'm not able to see it. The application provides a layer of REST api's for the UI. The UI (using react) is currently in netlify.com and has successfully deployed.
Actions taken
- Clone the application repository onto the ec2 machine
- Run "npm install" from the root of the application on the ec2 machine
- Navigate (using the SSH terminal) to the root of the application and run the following command
Command
pm2 start src/index.js
The output from the command say "online" in green. The contents of the index.js file is below - very simple stuff
index.js
const app = require('./app');
const port = 5000;
app.listen(port, () => {
/* eslint-disable no-console */
/* eslint-enable no-console */
});
To see if it works whilst on the EC2 I try the following within the SSH session
curl https://localhost:5000 (have also tried http://localhost:5000)
but the command responds with
curl: (7) Failed to connect to localhost port 5000: Connection refused
Question - is this the way to deploy express/ node applications into AWS? It's my just time :-|