Starting Postgres automatically


Do you have any suggestions as to how the PostgreSQL service could be started automatically?

Autostart services
Setting up PostgreSQL

I’m not aware of any way to do this so I think you’ll need to start it manually. If you’re on a premium account and using a hot workspace then your server and database will stay running for a longer time than if you’re on a free account but it’s not an “always on” situation.


You can add the startup command to ~/.profile.


You would need to add it to each workspace that you use PostgreSQL in.


IF you want to have the PostgreSQL start automatically:
Click on the Gear icon in Open files.
Check “Show Home in Favorites” and "Show Hidden Files"
in the top directory ~-. you will see the .profile (hidden file) open it for editing and put this in at bottom…

function checkstart {
service=1 if [[ ! (ps -ef | grep -v grep | grep “$service” | wc -l) > 0 ]]
sudo service $service start &
checkstart postgresql

this will check if PostgreSQL database is running and if not it will start it whenever you launch a shell - which it does when you restart your workspace. Hope this helps!


This did not work for me in my node workspace. However, I got PostgreSQL to start automatically using the following in my ~/.profile:
function checkstart {
if ! pgrep -xc postgres > 0
echo "starting $service"
sudo service $service start
checkstart postgresql

In addition, I could not get the ~/.profile to show up in the file tree so I used a terminal
cd ~
ls -la

I then scrolled through to find .profile
By clicking on the file name I could select ‘open’ to edit the file in the main editor.
Sometimes I have to click twice, first to ‘set the context’, then again to activate the context menu.