Report this

What is the reason for this report?

Postgres stopped running, is there a way I can get alerts if this happens?

Posted on August 19, 2017

I recently realized my site was down, and after I checked the logs I noticed I couldn’t connect to postgres. Once I started postgres the site was back up.

Couple of questions:

  • What might cause postgres to stop?
  • What’s a way that I could get an alert if my site goes down?


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!

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.

Then you would need to check postgres logs to find out why it crashes.

Hello there,

The best place to start is to check the server logs. This can shed more light on why the service was stopped.

You can create a simple script to check if Postgresql is running and if not to start the service.

  1. #!/bin/bash
  2. # Check if MySQL is running
  3. sudo systemctl status postgresql.service > /dev/null 2>&1
  4. # Restart the MySQL service if it's not running.
  5. if [ $? != 0 ]; then
  6. sudo systemctl start postgresql.service
  7. fi

Regards

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.