Pardon my n00biness here. I've set up a simple website app through AngularJS and NodeJS on Ubuntu 14.04. After starting my server, the IP address doesn't load and throws a connection failure error.
I've been able to successfully connect to the Ubuntu server on AWS
successfully installed npm, node, and pulled git repo
tried launching the server by entering "sudo nodejs server.js" in API folder
server launches, but IP address doesn't load project .. no errors in console..
These were my steps in Terminal from start to finish after logging into my SSH server:
ubuntu@ip-172-31-25-241:~$ sudo mkdir src
ubuntu@ip-172-31-25-241:~$ cd src
ubuntu@ip-172-31-25-241:~/src$ sudo git init (after installing git)
ubuntu@ip-172-31-25-241:~/src$ sudo git pull origin master (pulled repo)
ubuntu@ip-172-31-25-241:~/src$ sudo apt-get install npm
ubuntu@ip-172-31-25-241:~/src$ sudo apt-get install nodejs
ubuntu@ip-172-31-25-241:~/src$ cd API
ubuntu@ip-172-31-25-241:~/src/API$ ls
server.js
ubuntu@ip-172-31-25-241:~/src/API$ sudo nodejs server.js
Server Started on http://localhost:8080
Press CTRL + C to stop server
Here is my code from my server.js file as requested by @JoKeRxbLaCk:
// initialize Express
var express = require('express');
// run Express
var app = express();
app.use(express.static(__dirname + './../APP'));
app.get('/', function(req, res) {
res.send('Express is running!');
});
app.listen(80, function() {
console.log('Server Started on http://localhost:8080');
console.log('Press CTRL + C to stop server');
});
When I try the command "nodejs server.js" instead of "sudo nodejs server.js", I get this error:
ubuntu@ip-172-31-25-241:~/src/API$ nodejs server.js
events.js:72
throw er; // Unhandled 'error' event
^
Error: listen EACCES
at errnoException (net.js:901:11)
at Server._listen2 (net.js:1020:19)
at listen (net.js:1061:10)
at Server.listen (net.js:1135:5)
at EventEmitter.listen (/home/ubuntu/src/node_modules/express/lib/application.js:617:24)
at Object.<anonymous> (/home/ubuntu/src/API/server.js:15:5)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
I expect the server to not throw an error and for my site to load :( Please help! I know I'm missing a step but can't figure out where.
node js
process withoutsudo
, so:nodejs server.js
. – JoKeRxbLaCkhttp://localhost:8080
orhttp://localhost:80
? Because you are setting in express to listen onport 80
, do you have annginx
orapache
that redirect fromport 8080
onport 80
? – JoKeRxbLaCk