0

I have an AngularJs 2 application working in development mode
being served by

webpack-development-server  

I wish to host this on EC2.

I have:
- created a linux instance
- installed node and npm
- cloned my repo from git
- ran

npm install 

from root where package.json is.
- ran

npm start  

but nothing happens.
Upon visiting the Amazon Public DNS Address,
I get an error:

enter image description here

Not Sure what I'm missing!
Help Please

package.json is:

enter image description here

Webpack common/production is:

enter image description here
enter image description here

tsconfig.json is:

enter image description here

7
  • Have you got the dist folder present or just source? Commented Dec 13, 2016 at 21:42
  • ./dist is there with all .js/.map/index.html files. Not sure why I can't get through. Commented Dec 13, 2016 at 21:45
  • Do you have http-server installed? Commented Dec 13, 2016 at 21:45
  • Within scripts in package.json in postinstall I did : sudo npm install -g htt-server Commented Dec 13, 2016 at 21:47
  • I see that now and if you run http-server from SSH do you get an error? Commented Dec 13, 2016 at 21:48

2 Answers 2

1

Install http-server globally using npm install http-server -g

run

sudo http-server dist -a 127.0.0.1 -p 80 --cors

because without -p it will default to port 8080 and you are trying port 80 via picture because you are running on port 80 this command will need to be run this under root permissions sudo prior to the command.

Replace 127.0.0.1 with your EC2 internal/private IP.

Check if http-server is listening on port 80

lsof -n -i:80 | grep LISTEN
Sign up to request clarification or add additional context in comments.

8 Comments

I have installed http-server globaly. I have tried to run http-server -p 80 but got **Error: listen EADDRNOTAVAIL 0.0.0.0:80. I also tried running with -a flag and the ec2 public dns address, but got the same error: Error: listen EADDRNOTAVAIL xxxx.xxxx.xxxx.xxxx:80
Please try http-server -a 127.0.0.1 -p 80 replace 127.0.0.1 with your private/internal IP address that is assigned to your EC2 instance.
I ran: http-server -p 80 -a 54.187.6.116 and I got ** Error: listen EADDRNOTAVAIL 54.187.6.116:80** Webpack compiles into ./dist, but then it crashes with this error.
That is your public IP. You can view the private IP on the AWS console.
Just ran: http-server -p 80 -a 172.31.11.171 but got: Error: listen EACCESS 172.31.11.171:80 from dist folder.
|
0

That's most likely a network connectivity issue, not a problem with your app.

Make sure that:

  1. The network ACL is allowing outgoing and incoming traffic on TCP port 80/443.
  2. The security group is allowing incoming traffic on TCP port 80/443.
  3. Your local firewall (iptables in most cases) is configured to allow incoming connections on TCP port 80/443.

1 Comment

I have checked all 3 instances of your answer and have all settings regarding 1,2 and 3 in order. thanx

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.