Problem trying to preview the running application. Possible Server issue with a practice project

preview

#1

Greetings, everyone. I’m studying through a Udemy course which involves practicing on Cloud9. I’m currently working on my first Express exercise, which is supposed to be available at:
https://express-1st-run-ktaherig.c9users.io/

My code thusly is:


var express = require(“express”);
var app = express();

// “/” => “Hi, there!“
app.get(”/”, function (req, res){
res.send(“Hi, there!”);
});

// “/bye” => “Goodbye!”
// “/dog” => “MEOW!”

// Tell Express to listen for requests (start server)

app.listen(process.env.PORT, process.env.IP, function(){
console.log(“The server has started”);
});


now, as the listener, I’ve also tried:

app.listen(8080, 0.0.0.0, function(){
console.log(“The server has started”);
});

and that doesn’t seem to work either. What am I doing wrong?


#2

what error do you see in terminal when running your application?


#3

#4

#5

This is my actual script:


#6

Your images did provide some insight, but I may or may not be able to help. In the first image, you ran node app.js and then ps aux and netstat -tulpn in order to test if it was running. The problem is, in order to test if it was running, you probably pressed Ctrl+C in order to get the interactive command line back. Unfortunately, if you press Ctrl+C in a running command, it stops running. So in that case, you stopped the server before checking if it was running, so it really wasn’t running anymore. The solution here would be to run node app.js in one terminal tab, leave it, then switch to another and test if it’s running from there.

Unfortunately, I don’t know why it wouldn’t work when using a runner. Usually, runners are quite reliable, so that would make me think it’s your code. I might be missing something, but your code looks fine, so I’m not quite sure what to do. My suggestion would be to follow my instructions for testing if the server is running in another terminal tab, and if it still doesn’t work, it might have to do with some sort of misconfiguration, or maybe there’s a problem in your code.


#7

It doesn’t work in an incognito tab, either. I can’t figure out why. In the Udemy video, it works fine, and I’m typing everything exactly the way the teacher types it. I really want to learn this, but I can’t figure out why it doesn’t work when I do it.