How to bring the PostgreSQL database back online?

image
I was just getting started on Building Mario Database course when encountered this problem. While trying to log in the database, there happened to be an issue with the its current status. The message said that port 5432 is down so I tried to turn it on but the operation is not permitted as shown in the image. What should I do to bring it back online?

Hi!

Can you try to exit the terminal with the command exit? Also, reload CodeRoad and then re-open the terminal. Now try to connect Postgres, it should work.

Thanks, it works (I didn’t think it was that easy though!)

I’m having the same problem, however, nothing is resolving it. I can’t get this to run on any browser. I got half way through the tut and then it all crashed. I’ve done the soft reset, i’ve logged out and back in again. Cookies are enabled. Nothing is working.

Can you share a screen shot @bgandhi - are you on the same project? The reset button should get everything set back up.

I found a fix on another help ticket. The issue was solved by going to:
View > Command Palette > CodeRaod: Start

I think this is a common enough issue that it should be the start page for each project. I’ve had to do this at least 3 more times today.

This worked for me:
psql --username=freecodecamp dbname=postgres

Hello everyone,

When I want to go back to my gitpod workspace and that this one has been shut down, when I start it again, I can’t connect to the database because it is not running.

I tried every advice mentionned in this topic but nothing works. The only thing that made something is the reset button in coderoad, after that I was able to connect to the psql server as freecodecamp user but… all my data were gone, e.g. the students database is none existant.
Someone understand what’s going on? How do I keep, or retrieve my data?

thanks

Hi @Nico-Jour

If postgreSQL is running and when you log in you do not see your database and tables, then the only way to reestablishing it is restoring a backup.
Normally, after I am done for the time or I am in a good place I issue, in the terminal, the command

pg_dump -cC --inserts -U freecodecamp data_base_name > data_base_name.sql

After I come back I restore it with the following command at the terminal.

psql -U postgres < data_base_name.sql

I do not have the internal knowledge how everything is running in Gitpod, but due to the nature that it does run in “containers”, and containers are ephemeral, which means their data is not persistent, I can see how the database can be a casualty of it. That’s why I back it up.

1 Like

Hello Wizardinaction!

Thank you for your response, that’s what I did after restarting the project from scratch.
And saving files in my computer too.

It seems containers aren’t a very good choice…

I do not want you to think the lesson here is that containers are not a good fit in this case. As everything in technology, knowledge and understanding are the important foundation to use. The issue perhaps is that in general technology has the tendency to hide and abstract for the sake of not exposing complexity to those that uses it. And in general developers of technologies (including coders), they try to emulate and live up to the idea from Arthur C. Clarke third law, that says:

Any sufficiently advanced technology is indistinguishable from magic

It is quite a thought experiment, if we consider that at face value, magic is misdirection, hiding and trickery. Enough said. :wink:

To bring a PostgreSQL database back online, you typically need to follow these steps:

  1. Check the PostgreSQL service status to ensure it’s stopped or inactive.
  2. Restart the PostgreSQL service using the appropriate command for your operating system (systemctl restart postgresql for Linux).
  3. Monitor the logs for any errors or issues that may arise during the restart process.
  4. Verify connectivity to the database to confirm it’s back online and accessible to users.

By executing these steps, you can successfully bring the PostgreSQL database back online and resume normal operations.