Reputation: 13
I'm new into node JS. I'm trying to install node and run just a 'Hello World' app but I have problems with my server.
When I try to run my app, the server is showing only the index files and not 'Hello World'. enter image description here
The node server is working and says that the http-server is available.
My code for my Hello World app:
var http = require("http");
http.createServer(function(req, res){
response.writeHead(200, {'Content-Type': 'text/plain'});
response.end('Hello World\n');
}).listen(8080);
console.log('Server running at http://192.168.178.14:8080/');
I want to run the file 'index.js' (second file in first screenshot). How can I fix this?
Upvotes: 1
Views: 1606
Reputation: 1515
As Mikael Lennholm and robertklep have mentioned in the comments, the issue is that you are trying to run a second server on the same address (:8080
).
I tested this myself to make sure, and here's the results I got:
Running an instance of the ecstatic server on :8080
, producing a very similar image to yours (using default code provided by ecstatic's documentation).
Attempting to run a regular server on the :8080
port gives me an error, EADDRINUSE :::8080
(which is expected, as the other application is already using that address). You should probably get this error when trying to run your application as well.
Now, either you or someone else is to blame. But the fact is that there is already a server running on port 8080
. I'd reccomend you try to find out who set it up (if it wasn't yourself) or maybe just try using another port. For example, 8088
:
Upvotes: 1