Not able to connect to PostgreSQL database in Linux Fedora via VS Code terminal

So I'm using Linux Fedora. I'm in my current Django project directory. When I dual booted, I did save my postgresql application and saved my database backup with pg_dump onto my removable drive before I booted to Linux.

I'm in VS Code, I installed all of the necessary packages/dependencies for my Django project. But before I can run Django server, I have to migrate my models to my db.

The problem, is that I'm not able to connect to my postgresql db and I need to do this before I run python manage.py migrate running python manage.py makemigrations CMD works fine.

So I'm new to Linux and I just need some help connecting to my db so that I can get my server running. Please keep in mind I'm using Fedora. I was able to install postgresql for Fedora with the following command

sudo dnf install postgresql-server postgresql-contribsudo dnf install postgresql-server postgresql-contrib

Here is the error I get in the console


Is the server running on that host and accepting TCP/IP connections?

connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused

Is the server running on that host and accepting TCP/IP connections?`

To be clear, I already have an existing database, so creating a new one is completely redundant. I also know my username, db name, password etc... Basically I just need help connecting to my PostgreSQL database, I tried establishing a database connection via pgAdmin GUI, however I'm not able to install pgAdmin on the website, since I'm using Fedora.

I was trying to follow the Fedora PostgreSQL docs, but I felt it was confusing. First of all, I already have a database created, in the docs tutorial, they use the CMD that assume I want to create a new database with no data in it.

I also tried installing PostreSQL on the official website, however the version for Fedora isn't listed on there.

I tried connecting to my database with pgAdmin, but that didn't turn out so smoothly as I'm on Linux Fedora 41 Workstation, before I was using Windows which made the pgAdmin set up easier.

Not sure if this helps or not, but I did save my PostgreSQL program saved on my USB drive along with other software applications before I dual booted to Linux. Ironically, PostgreSQL that was saved on my C drive was somehow transferred to my Local Disk as well as my backup database.

Not sure why it's in my Local Drive, kind of redundant seeing that I used a flash drive to save the programs I need for my project. But I was expecting the process to be straightforward to connect to my PostgreSQL database, so that I can finally migrate my models.

These are the approaches I tried.

Вернуться на верх