James
James

Reputation: 777

How to deploy node/ express application into AWS

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

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 :-|

Upvotes: 0

Views: 331

Answers (1)

bot
bot

Reputation: 1423

You might want to add an inbound rule to allow TCP traffic at port 5000 in the security group attached to your instance read here. If you want to use any port on your EC2 instance you have to add an inbound rule (or outbound rule depending on your use case) in the security group.

Upvotes: 1

Related Questions