how do i connect the Postgis template with the postgres database
scoolj
HOBBYOP

8 months ago

File "C:\Users\scool\Documents\Dev\pikgo-backend\venv\Lib\site-packages\django\db\backends\utils.py", line 103, in _execute

return self.cursor.execute(sql)

^^^^^^^^^^^^^^^^^^^^^^^^

psycopg2.errors.FeatureNotSupported: extension "postgis" is not available

DETAIL: Could not open extension control file "/usr/share/postgresql/16/extension/postgis.control": No such file or directory.

HINT: The extension must first be installed on the system where PostgreSQL is running.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):

File "C:\Users\scool\Documents\Dev\pikgo-backend\manage.py", line 22, in <module>

main()

File "C:\Users\scool\Documents\Dev\pikgo-backend\manage.py", line 18, in main

execute_from_command_line(sys.argv)

File "C:\Users\scool\Documents\Dev\pikgo-backend\venv\Lib\site-packages\django\core\management\__init__.py", line 442, in execute_from_command_line

utility.execute()

File "C:\Users\scool\Documents\Dev\pikgo-backend\venv\Lib\site-packages\django\core\management\__init__.py", line 436, in execute

self.fetch_command(subcommand).run_from_argv(self.argv)

File "C:\Users\scool\Documents\Dev\pikgo-backend\venv\Lib\site-packages\django\core\management\base.py", line 416, in run_from_argv

self.execute(*args, **cmd_options)

File "C:\Users\scool\Documents\Dev\pikgo-backend\venv\Lib\site-packages\django\core\management\base.py", line 460, in execute

output = self.handle(*args, **options)

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "C:\Users\scool\Documents\Dev\pikgo-backend\venv\Lib\site-packages\django\core\management\base.py", line 107, in wrapper

res = handle_func(*args, **kwargs)

^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "C:\Users\scool\Documents\Dev\pikgo-backend\venv\Lib\site-packages\django\core\management\commands\migrate.py", line 112, in handle

connection.prepare_database()

File "C:\Users\scool\Documents\Dev\pikgo-backend\venv\Lib\site-packages\django\contrib\gis\db\backends\postgis\base.py", line 119, in prepare_database

cursor.execute("CREATE EXTENSION IF NOT EXISTS postgis")

File "C:\Users\scool\Documents\Dev\pikgo-backend\venv\Lib\site-packages\django\db\backends\utils.py", line 122, in execute

return super().execute(sql, params)

^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "C:\Users\scool\Documents\Dev\pikgo-backend\venv\Lib\site-packages\django\db\backends\utils.py", line 79, in execute

return self._execute_with_wrappers(

^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "C:\Users\scool\Documents\Dev\pikgo-backend\venv\Lib\site-packages\django\db\backends\utils.py", line 92, in executewith_wrappers

return executor(sql, params, many, context)

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

File "C:\Users\scool\Documents\Dev\pikgo-backend\venv\Lib\site-packages\django\db\backends\utils.py", line 100, in _execute

with self.db.wrap_database_errors:

File "C:\Users\scool\Documents\Dev\pikgo-backend\venv\Lib\site-packages\django\db\utils.py", line 91, in exit

raise dj_exc_value.with_traceback(traceback) from exc_value

File "C:\Users\scool\Documents\Dev\pikgo-backend\venv\Lib\site-packages\django\db\backends\utils.py", line 103, in _execute

return self.cursor.execute(sql)

^^^^^^^^^^^^^^^^^^^^^^^^

django.db.utils.NotSupportedError: extension "postgis" is not available

DETAIL: Could not open extension control file "/usr/share/postgresql/16/extension/postgis.control": No such file or directory.

HINT: The extension must first be installed on the system where PostgreSQL is running.

$10 Bounty

12 Replies

Railway
BOT

8 months ago

Hey there! We've found the following might help you get unblocked faster:

If you find the answer from one of these, please let us know by solving the thread!


scoolj
HOBBYOP

8 months ago

It is working perfectly on my local machine but when i deploy i start having issues


chandrika
EMPLOYEE

8 months ago

This thread has been marked as public for community involvement, as it does not contain any sensitive or personal information. Any further activity in this thread will be visible to everyone.

Status changed to Open chandrika 8 months ago


scoolj
HOBBYOP

8 months ago

I am still waiting for assistance @ admin


clashing
HOBBY

8 months ago

These seems to be the error coming from your local machine, as they contain path to local disks!

What are the Railway-specific issues you are seeing on the platform? Provide a screenshot of those


scoolj
HOBBYOP

8 months ago

When i deployed postgis template how do connect it to an existing postgres database instance already in used?


clashing
HOBBY

8 months ago

You can use the following steps to connect it to your existing DB instance:

1. Copy connection details from the existing DB

  • Go to the Railway UI/dashboard

  • Select the existing PostgreSQL database instance

  • Find the Connect tab or section

  • Copy the connection details—especially the DATABASE_URL (looks like: postgresql://user:password@host:port/dbname)

2. Add DATABASE_URL to the App's environment variables

  • Go to the app’s service in the Railway project

  • Open the Variables (Environment) tab

  • Add a new environment variable named DATABASE_URL and paste the copied connection URL

Then you can use the DB instance in your python file, as you do in local development.

Redeploy the service, and it should work fine.


scoolj
HOBBYOP

8 months ago

Yeah. This works for the postgres but I needed to deploy new instance of POSTGIS. am going to connect it to the existing postgres instance or am going to be using postgis as the new full fledge database since it is refered as an extension.


clashing
HOBBY

8 months ago

You can connect it to the existing POSTGRES instance, it won't throw any error as far as I know. You can give it a try


scoolj

Yeah. This works for the postgres but I needed to deploy new instance of POSTGIS. am going to connect it to the existing postgres instance or am going to be using postgis as the new full fledge database since it is refered as an extension.

clashing
HOBBY

8 months ago

If it's solved, then please mark my previous reply as the solution wink emoji


scoolj
HOBBYOP

8 months ago

I have but it was giving error


clashing

If it's solved, then please mark my previous reply as the solution

scoolj
HOBBYOP

8 months ago

What I meant was that I have tried that and it works, but I am trying to connect the PostGIS template with the existing database so that I can continue from where we left off.


clashing
HOBBY

8 months ago

Can you provide the build logs, or the error which is showing at your side while connecting?


Loading...