I just started to host my SailsJS app on EC2 and I'm struggling so much. I cannot get the app to run on port 80. So what I did was I changed the default apache listening port of 80 to 8080.
But still Sails cannot be lifted and I get this error.
warn: error raised: Error: listen EACCES
error: Server doesn't seem to be starting.
error:
error: Troubleshooting tips:
error:
error: -> Do you have permission to use port 80 on this system? (you might try `sudo`)
error:
error: -> Is something else already running on port 80 ?
error:
error: -> Are you deploying on a platform that requires an explicit hostname, like OpenShift?
error: (Try setting the `explicitHost` config to the hostname where the server will be accessible.)
error: (e.g. `mydomain.com` or `183.24.244.42`)
As it says I tried Sudo, But then the app starts. Cool.
Then I get all these errors on the terminal
warn: websocket connection invalid
warn: websocket connection invalid
warn: websocket connection invalid
warn: websocket connection invalid
And this error on my browser console
WebSocket connection to 'ws://mywebsite.co/socket.io/1/websocket/GXGSRKCiYhST-7CMcXkm?__sails_io_sdk_version=0.10.0&__sails_io_sdk_platform=browser&__sails_io_sdk_language=javascript' failed: Connection closed before receiving a handshake response
This is the ubuntu > netstat if that help in anywhy to understand
$ netstat
Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 localhost:mysql localhost:51432 TIME_WAIT
tcp 0 0 localhost:mysql localhost:51433 TIME_WAIT
tcp 0 308 ip-172-31-28-139.ap:ssh 121.75.215.208:55402 ESTABLISHED
Active UNIX domain sockets (w/o servers)
Proto RefCnt Flags Type State I-Node Path
unix 4 [ ] DGRAM 8490 /dev/log
unix 3 [ ] STREAM CONNECTED 8369
unix 3 [ ] STREAM CONNECTED 7920 @/com/ubuntu/upstart
unix 3 [ ] STREAM CONNECTED 8392
unix 3 [ ] STREAM CONNECTED 9978
unix 2 [ ] DGRAM 9832
unix 3 [ ] STREAM CONNECTED 8391
unix 3 [ ] STREAM CONNECTED 9979 /var/run/dbus/system_bus_socket
unix 3 [ ] STREAM CONNECTED 8403 @/com/ubuntu/upstart
unix 3 [ ] DGRAM 7519
unix 3 [ ] STREAM CONNECTED 8406 /var/run/dbus/system_bus_socket
unix 2 [ ] DGRAM 8696
unix 3 [ ] STREAM CONNECTED 8483
unix 3 [ ] STREAM CONNECTED 8484 /var/run/dbus/system_bus_socket
unix 3 [ ] STREAM CONNECTED 7890
unix 3 [ ] DGRAM 7520
unix 3 [ ] STREAM CONNECTED 8405
unix 3 [ ] STREAM CONNECTED 7468
unix 3 [ ] STREAM CONNECTED 9973
unix 3 [ ] STREAM CONNECTED 7481 @/com/ubuntu/upstart
unix 3 [ ] STREAM CONNECTED 9972
It seems like there are unclosed connections from the app
As you may see here. So the app is never closed because of the web sockets
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 584 0 ip-173-31-28-139.a:1337 121.75.215.208:57749 CLOSE_WAIT 6468/node
tcp 493 0 ip-173-31-28-139.a:1337 121.75.215.208:57748 CLOSE_WAIT 6468/node
tcp 0 596 ip-173-31-28-139.ap:ssh 121.75.215.208:56740 ESTABLISHED -
tcp 449 0 ip-173-31-28-139.a:1337 121.75.215.208:57872 ESTABLISHED -
tcp 493 0 ip-173-31-28-139.a:1337 121.75.215.208:57745 CLOSE_WAIT 6468/node
tcp 0 0 localhost:mysql localhost:51494 ESTABLISHED -
tcp 1 0 ip-173-31-28-139.a:1337 121.75.215.208:57873 CLOSE_WAIT -
tcp 7 0 ip-173-31-28-139.a:1337 121.75.215.208:57780 CLOSE_WAIT 6468/node
tcp 499 0 ip-173-31-28-139.a:1337 121.75.215.208:57744 CLOSE_WAIT 6468/node
tcp 0 0 localhost:mysql localhost:51493 ESTABLISHED -
tcp 584 0 ip-173-31-28-139.a:1337 121.75.215.208:57746 CLOSE_WAIT 6468/node
tcp 0 0 localhost:51494 localhost:mysql ESTABLISHED 6468/node
tcp 0 0 localhost:51493 localhost:mysql ESTABLISHED 6468/node
tcp 0 0 ip-173-31-28-139.ap:ssh 121.75.215.208:55402 ESTABLISHED -
tcp 499 0 ip-173-31-28-139.a:1337 121.75.215.208:57747 CLOSE_WAIT 6468/node
Please help if you have done this in your life. I'm happy to delete all my configuration and start from scratch.
From the fact that you mentioned "default Apache port", I'm guessing you're starting with an AMI that's not necessarily optimal for Node apps. I would suggest starting with the Bitnami Node.js AMI on EC2. I haven't had any problems setting up Sails apps on EC2 instances using that AMI. It probably doesn't come pre-installed with MySQL, but that's what apt-get is for, right?