简体   繁体   中英

Node.js on Amazon AWS goes down when Putty SSH is disconnected

I just set up my first Amazon AWS server, with a Node.js installation on it. I run my app, at which point Node says that it's listening on port 3000. However, if I close my laptop, Node.js is no longer reachable through my app. How can I make it run even when I'm not logged in to the server through Putty? As a follow-up question, how can I re-open the Node instance (so that I see the any console.log messages from it) when I log back in to my server?

Thank you!

This is part StackOverflow, part Serverfault question I believe. It sounds like the problem is you're running the node server in the foreground of your SSH session, but you'd rather run it like a service (in the background).

When you exec something like that simple node server, you're running it (by default) in your SSH connection, which ends when your connection terminates from sleeping your computer. Some scripts/programs will run by default in the background, but if you're seeing results in STDOUT (printing to the shell) it is running in the foreground.

Highjacking these answers: Node.js as a background service

Two solutions

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM