My application seems to not show when I click "preview running application"


#1

Here is the error I receive

No application seems to be running here!
Cloud9 can't get you to your requested workspace. Here are some suggestions on how to figure out what's going on:

Check that the workspace name (portfolio) and username (thec0mposer) are typed correctly.
Check that the server is successfully running on Cloud9:
If the server hit an error, the output window will have a message telling you what it is
If you're in the middle of debugging code, your server might be paused right now
The server might be running on a different port; make sure it's on port $PORT with $IP as the IP address
Status Page | Support | Dashboard | Home

I read the docs and came across this

ENVIRONMENT VARIABLES
Make sure to use the environment variable $PORT in your application so that you can preview your application. For example, in an node.js application you would use process.env.PORT, in a python application that would be os.environ['PORT'].

Currently $PORT defaults to 8080 but this may change in the future.

Wondering if that has anything to do with it.


#2

Yes. in order to run your application you must be using port 8080.


#3

In the docs, they are saying “If you’re developing a server application, please note that you need to listen to 0.0.0.0 ($IP) and 8080 ($PORT). Listening to this port will enable your app to be viewable at http://-.c9users.io”

What exactly dose “listening” mean. When I used PhPStorm I was using MAMP, so I could adjust the port just by opening mamp and doing it that way. I take it this is going to require a couple terminal commands, if so what would they be?


#4

Do you use one of built in runners or run your app from commandline?
In which project do you see the error?


#5

@harutyun
The project named “Portfolio”, is the one I am referring to. I’m a little confused when you say “built in runners”. I’ve only set up a localhost twice; one being with Vagrant through a VM, and the other was simply adjusting the settings in MAMP. So as far as confirming the $PATH and 8080 and all that is correct, I’ve yet to gain any actual experience within those areas.

  • Seth

P.S. I typically just click the Run button at the top of the IDE layout, and then I’ll go under tools, click preview running application.


#6

The application doesn’t seem to have any server side code, so you can just use preview>live preview with html tab open, to see your app without running any server. Alternatively you can use run button to start apache and then open application preview. There is no need to set up port or install anything.


#7

One thing I noticed is that I can indeed go under tools/preview/live preview file. This will only show the actual code on the page. I’m working with Angular, Sass, and CSS. When I preview the file, their code appears, there solid raw code, not their functionality; I’m currently using Codepen, so I’d like to see a live demonstration of what I’m working on so I can style the project.

  • Seth

#8

I have my listener set to:

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

and my URL is:
https://express-1st-run-ktaherig.c9users.io/

And it just very simply doesn’t run. What am I doing wrong?


#9

Change your listener to-

app.listen(process.env.PORT, process.env.IP);

Means you need to listen to 8080 (port), and 0.0.0.0 (IP addr). Hopefully, it’ll work!


#10

That actually does work. Thank you very much, Sharma!