Question

How do ensure that server in droplet does not stop once I discconnect SSH connection from my local machine

I have created a droplet that hosts a server. Droplet has Ubuntu as OS. For setting up the server in the droplet, I have accessed the droplet console through SSH public key from a local ubuntu machine. The server is spun successfully. However, closing the SSH connection kills all live sessions of the server. How Do I ensure that server continues to spin even after I kill the SSH connection?


Submit an answer
Answer a question...

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

alexdo
Site Moderator
Site Moderator badge
December 27, 2022

Hello @mandargite

Can you share details about the configuration of the server you run inside the Ubuntu droplet?

I’ll recommend using Docker to run containers if possible. In this way, you’ll have more access in terms of managing the containers and access via ssh when needed.

https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-on-ubuntu-20-04

Regards

KFSys
Site Moderator
Site Moderator badge
December 26, 2022

Hi @mandargite,

I’ll recommend using PM2. Here is a tutorial which will help you configure it :

https://www.digitalocean.com/community/tutorials/how-to-use-pm2-to-setup-a-node-js-production-environment-on-an-ubuntu-vps

This tutorial aims to help you setup up an Ubuntu server to run Node.js applications, including apps based on Express, Geddy, or Sails. These instructions will help you avoid some security mistakes, as well as provide some surprising benefits such as:

  • You will not run your app as root; therefore, your app will be more secure.

  • You will be using port 80 to run your app, which typically can only be accessed by the root user. (You will able to run your app using a custom URL such as http://mysite.com - but you will not have to specify a port.)

  • Your application will restart if it crashes, and it will keep a log of unhandled exceptions.

  • Your application will restart when the server starts - i.e. it will run as a service.

Now, if you are using a different service, there are other tutorials which include PM2.