skip to Main Content

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.

2

Answers


  1. Chosen as BEST ANSWER

    I think I figured out why I'm not able to run python manage.py migrate successfully. I did some research via Google.

    It turns out my problem lies in the pg_hba.conf file. I think I have to replace Ident with md5, just have to figure where specifically to add md5


  2. PostgreSQL installers often default to a ‘secure’ installation, with no external network access enabled. If you can connect to the database with a local psql client, try connecting using the same credentials as in your program. If that fails, you have identified the problem, PostgreSQL is not listening on external networks. You can correct this a few ways:

    • Modify your code to use a local (localhost or unix-domain socket) connection, rather than the network connection you currently have.
    • Modify the PostgreSQL configuration to listen on network interfaces. This is usually unnecessary for dev instances.
    • Use a development server on the network; this does require you to have network access to the development server to do any actual work.

    I listed these in what I think would be easiest-to-hardest order, your experience may differ.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search