# Determining the PostgreSQL and PostGIS versions

> Check which PostgreSQL and PostGIS versions are installed, using the command line or a SQL query.

Source: https://helpcenter.ruachost.com/developers/databases/determining-the-postgresql-and-postgis-versions/

> **PostgreSQL is available on Managed VPS only:**
Ruachost shared hosting supports MySQL (MariaDB) databases, not PostgreSQL. To use PostgreSQL, choose a [Managed VPS](https://ruachost.com/vps).

When working with PostgreSQL and PostGIS, it’s important to know which versions are installed on your hosting account. On **ruachost.com**, you can check these versions directly from the command line or within SQL queries.

## Why Check Versions?

- Ensure compatibility with applications and extensions.
- Verify support for specific features.
- Troubleshoot errors related to outdated versions.

## Steps to Determine PostgreSQL Version

### Method 1: Using Command Line

1. Log in to your hosting account via SSH.
2. Run the following command:

   ```bash
   psql --version
   ```

   Example output:

   ```
   psql (PostgreSQL) 14.2
   ```

### Method 2: Using SQL Query

1. Connect to PostgreSQL using `psql`:

   ```bash
   psql -U username dbname
   ```
2. Run the query:

   ```
   SELECT version();
   ```

   Example output:

   ```
   PostgreSQL 14.2 on x86_64-pc-linux-gnu, compiled by gcc, 64-bit
   ```

   ```
   ```

## Steps to Determine PostGIS Version

### Method 1: Using SQL Query

1. Connect to your database with `psql`.
2. Run the query:

   ```
   SELECT PostGIS_Version();
   ```

   Example output:

   ```
   3.1 USE_GEOS=1 USE_PROJ=1 USE_STATS=1
   ```

### Method 2: Using Extended Function

```
SELECT PostGIS_Full_Version();
```

This provides detailed information about PostGIS, GEOS, PROJ, and other libraries.

> **Important Notes:**
- Replace `username` and `dbname` with your actual PostgreSQL credentials.
- Ensure PostGIS is installed on your database before running PostGIS queries.
- If PostGIS functions return errors, the extension may not be enabled. You can enable it with:

  ```
  CREATE EXTENSION postgis;
  ```
