# Postgresql version issues

**URL:** <https://forum.djangoproject.com/t/postgresql-version-issues/15972>\
**Category:** Deployment\
**Created:** [September 14, 2022, 3:00pm UTC](https://forum.djangoproject.com/t/postgresql-version-issues/15972 "2022-09-14T15:00:29Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![gooblegobble](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/gooblegobble/32/10080_2.png) [@gooblegobble](https://forum.djangoproject.com/u/gooblegobble)\
**Post date:** [September 14, 2022, 3:00pm UTC](https://forum.djangoproject.com/t/postgresql-version-issues/15972/1 "2022-09-14T15:00:29Z")

</div>

I am in the initial stages of setting up a Django project, and I’m having an issue–the short version of my question is how do I find where Django is getting the postgresql version information from?

Here are the details:

Development environment: Linux Mint 20.3  
Python version in the virtual environment: 3.8.10

When I run this from within the virtual environment, I get:

$ psql --version  
psql (PostgreSQL) 12.12 (Ubuntu 12.12-0ubuntu0.20.04.1)

My installation within the venv has:

psycopg2 version: 2.9.3  
Django version: 4.1.1

I set up my database, changed the relevant settings to postgresql requirements following the docs, but when I try

$ python manage.py runserver,

I get a NotSupportedError:

django.db.utils.NotSupportedError: PostgreSQL 11 or later is required (found 10.21).

So, where is Django seeing this version of PostgreSQL? I can provide further details of my setup if needed, but it seems like a basic installation issue to me…

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [September 14, 2022, 3:05pm UTC](https://forum.djangoproject.com/t/postgresql-version-issues/15972/2 "2022-09-14T15:05:16Z")

</div>

Have you verified that you _don’t_ have a second version of PostgreSQL installed?

Double-check your settings file to ensure you’re connecting to the right host/port.

---

<div class="post-metadata">

**Author:** ![gooblegobble](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/gooblegobble/32/10080_2.png) [@gooblegobble](https://forum.djangoproject.com/u/gooblegobble)\
**Post date:** [September 14, 2022, 3:30pm UTC](https://forum.djangoproject.com/t/postgresql-version-issues/15972/3 "2022-09-14T15:30:09Z")

</div>

Well, I have 5432 specified in my settings as my port, and when I run

(venv) $ psql -p 5432 dbname dbuser

I can connect to the database fine, and it shows the 12.12 version. You can probably guess from the fact that I am asking this question that I do _not_ know how to figure out whether there is a second version of postgresql in that environment that Django is seeing. So any hints for how I might do that would be useful.

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [September 14, 2022, 3:59pm UTC](https://forum.djangoproject.com/t/postgresql-version-issues/15972/4 "2022-09-14T15:59:45Z")

</div>

Post your `DATABASES` section of your settings file, that’ll help some.

I’m not specifically familiar with Mint - I don’t know what it uses for package management (apt/dpkg? yum? something else?) and therefore don’t know how to verify what packages may be installed.

(I’m assuming you’re running your database locally and not connecting to a remote server.)

You could do a `ps -AF` as root to see what all is running - it should be fairly obvious which entries are for postgresql.

---

<div class="post-metadata">

**Author:** ![gooblegobble](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/gooblegobble/32/10080_2.png) [@gooblegobble](https://forum.djangoproject.com/u/gooblegobble)\
**Post date:** [September 15, 2022, 11:59am UTC](https://forum.djangoproject.com/t/postgresql-version-issues/15972/5 "2022-09-15T11:59:47Z")

</div>

Ah, yes, I do see that both 12 and 10 are installed on the system. This might be from an earlier version of Mint (which is like Ubuntu, Debian-based and uses apt and dpkg).

Here’s my DATABASES entry from settings:

DATABASES = {  
‘default’: {  
‘ENGINE’: ‘django.db.backends.postgresql’,  
‘NAME’: ‘dbname’,  
‘USER’: ‘darkhelmet’,  
‘HOST’: ‘localhost’,  
‘PASSWORD’: ‘12345’,  
‘PORT’: ‘’,  
‘CONN\_MAX\_AGE’: 1000,  
‘OPTIONS’: {  
‘isolation\_level’: psycopg2.extensions.  
ISOLATION\_LEVEL\_SERIALIZABLE,  
},  
}  
}

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [September 15, 2022, 12:10pm UTC](https://forum.djangoproject.com/t/postgresql-version-issues/15972/6 "2022-09-15T12:10:50Z")

</div>

You’re not specifying a port on your connection, I don’t know how Django would figure out which to use. I’d suggest you either remove the version 10 or specify the version 12 port on your connection, or both.

---

<div class="post-metadata">

**Author:** ![gooblegobble](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/gooblegobble/32/10080_2.png) [@gooblegobble](https://forum.djangoproject.com/u/gooblegobble)\
**Post date:** [September 15, 2022, 1:14pm UTC](https://forum.djangoproject.com/t/postgresql-version-issues/15972/7 "2022-09-15T13:14:19Z")

</div>

Actually, nothing changes when I specify the port (5432, as in the previous post). It’s the default, and when I connect to the db outside Django, it works correctly.

Hmm, I’m not sure if it would be safe to remove version 10. Okay, I’ll keep tinkering.

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [September 15, 2022, 3:42pm UTC](https://forum.djangoproject.com/t/postgresql-version-issues/15972/8 "2022-09-15T15:42:19Z")

</div>

If you don’t want to remove it, you could stop it from running - that may be sufficient. You could also change it such that it’s running on a different port.

---

<div class="post-metadata">

**Author:** ![ariroffe](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/ariroffe/32/10098_2.png) [@ariroffe](https://forum.djangoproject.com/u/ariroffe)\
**Post date:** [September 17, 2022, 2:14pm UTC](https://forum.djangoproject.com/t/postgresql-version-issues/15972/9 "2022-09-17T14:14:17Z")

</div>

I was having the same issue (in Ubuntu).

If you go to `/etc/postgresql` you’ll find subdirectories for each of the installed versions of postgres. Inside each you’ll find a `postgresql.conf` file that specifies the port each version is running on.

For instance, in my case `etc/postgresql/10/main/postgres.conf` specifies that version 10 is running on port 5432, while `etc/postgresql/14/main/postgres.conf` is running on port 5434. You can then modify your `settings.py`. Just set the port to the one that the postgres version you want is running on.

Additionaly, notice that you may have a newer version of psql connecting to an older version of postgres. For instance, like you, if I do `psql --version` it shows the latest (14.5). However, actually going into `sudo -u postgres psql` will show:

```auto
psql (14.5 (Ubuntu 14.5-0ubuntu0.22.04.1), server 10.14 (Ubuntu 10.14-0ubuntu0.18.04.1))

```

The `server` is (I think) the postgres version that psql it is connecting to. I believe this is because psql is connecting to port 5432 by default. Hence, to create your database, user, etc. you should do `sudo -u postgres psql -p [PORT]`.

Hope this helps!

---

<div class="post-metadata">

**Author:** ![gooblegobble](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/gooblegobble/32/10080_2.png) [@gooblegobble](https://forum.djangoproject.com/u/gooblegobble)\
**Post date:** [September 19, 2022, 2:03pm UTC](https://forum.djangoproject.com/t/postgresql-version-issues/15972/10 "2022-09-19T14:03:38Z")

</div>

Thanks, this was it–there was a lot of useful information in /etc/postgresql that sorted me out.
