Error when migrate ...
 
Notifications
Clear all

Error when migrate to live server on deployment part after installing GDAL and PostGIS on live server

7 Posts
2 Users
0 Reactions
28 Views
0
Topic starter

Sir, an error come whenever I run 'python manage.py migrate' in the live server. do I need to change all the database configuration on settings.py in the .env files?
there is no problem on running on local server until now. I got error only when I want to migrate the postgres to the live server..

Traceback (most recent call last):

  File "/home/jajamionline/jajamionline-dir/env/lib/python3.12/site-packages/django/db/backends/base/base.py", line 279, in ensure_connection

    self.connect()

  File "/home/jajamionline/jajamionline-dir/env/lib/python3.12/site-packages/django/utils/asyncio.py", line 26, in inner

    return func(*args, **kwargs)

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

  File "/home/jajamionline/jajamionline-dir/env/lib/python3.12/site-packages/django/db/backends/base/base.py", line 256, in connect

    self.connection = self.get_new_connection(conn_params)

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

  File "/home/jajamionline/jajamionline-dir/env/lib/python3.12/site-packages/django/contrib/gis/db/backends/postgis/base.py", line 126, in get_new_connection

    connection = super().get_new_connection(conn_params)

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

  File "/home/jajamionline/jajamionline-dir/env/lib/python3.12/site-packages/django/utils/asyncio.py", line 26, in inner

    return func(*args, **kwargs)

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

  File "/home/jajamionline/jajamionline-dir/env/lib/python3.12/site-packages/django/db/backends/postgresql/base.py", line 350, in get_new_connection

    connection = self.Database.connect(**conn_params)

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

  File "/home/jajamionline/jajamionline-dir/env/lib/python3.12/site-packages/psycopg2/__init__.py", line 122, in connect

    conn = _connect(dsn, connection_factory=connection_factory, **kwasync)

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

psycopg2.OperationalError: connection to server at "localhost" (::1), port 5434 failed: Connection refused

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

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

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

 

 

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

 

Traceback (most recent call last):

  File "/home/jajamionline/jajamionline-dir/manage.py", line 22, in <module>

    main()

  File "/home/jajamionline/jajamionline-dir/manage.py", line 18, in main

    execute_from_command_line(sys.argv)

  File "/home/jajamionline/jajamionline-dir/env/lib/python3.12/site-packages/django/core/management/__init__.py", line 442, in execute_from_command_line

    utility.execute()

  File "/home/jajamionline/jajamionline-dir/env/lib/python3.12/site-packages/django/core/management/__init__.py", line 436, in execute

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

  File "/home/jajamionline/jajamionline-dir/env/lib/python3.12/site-packages/django/core/management/base.py", line 413, in run_from_argv

    self.execute(*args, **cmd_options)

  File "/home/jajamionline/jajamionline-dir/env/lib/python3.12/site-packages/django/core/management/base.py", line 459, in execute

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

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

  File "/home/jajamionline/jajamionline-dir/env/lib/python3.12/site-packages/django/core/management/base.py", line 107, in wrapper

    res = handle_func(*args, **kwargs)

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

  File "/home/jajamionline/jajamionline-dir/env/lib/python3.12/site-packages/django/core/management/commands/migrate.py", line 116, in handle

    connection.prepare_database()

  File "/home/jajamionline/jajamionline-dir/env/lib/python3.12/site-packages/django/contrib/gis/db/backends/postgis/base.py", line 115, in prepare_database

    with self.cursor() as cursor:

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

  File "/home/jajamionline/jajamionline-dir/env/lib/python3.12/site-packages/django/utils/asyncio.py", line 26, in inner

    return func(*args, **kwargs)

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

  File "/home/jajamionline/jajamionline-dir/env/lib/python3.12/site-packages/django/db/backends/base/base.py", line 320, in cursor

    return self._cursor()

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

  File "/home/jajamionline/jajamionline-dir/env/lib/python3.12/site-packages/django/db/backends/base/base.py", line 296, in _cursor

    self.ensure_connection()

  File "/home/jajamionline/jajamionline-dir/env/lib/python3.12/site-packages/django/utils/asyncio.py", line 26, in inner

    return func(*args, **kwargs)

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

  File "/home/jajamionline/jajamionline-dir/env/lib/python3.12/site-packages/django/db/backends/base/base.py", line 278, in ensure_connection

    with self.wrap_database_errors:

  File "/home/jajamionline/jajamionline-dir/env/lib/python3.12/site-packages/django/db/utils.py", line 91, in __exit__

    raise dj_exc_value.with_traceback(traceback) from exc_value

  File "/home/jajamionline/jajamionline-dir/env/lib/python3.12/site-packages/django/db/backends/base/base.py", line 279, in ensure_connection

    self.connect()

  File "/home/jajamionline/jajamionline-dir/env/lib/python3.12/site-packages/django/utils/asyncio.py", line 26, in inner

    return func(*args, **kwargs)

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

  File "/home/jajamionline/jajamionline-dir/env/lib/python3.12/site-packages/django/db/backends/base/base.py", line 256, in connect

    self.connection = self.get_new_connection(conn_params)

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

  File "/home/jajamionline/jajamionline-dir/env/lib/python3.12/site-packages/django/contrib/gis/db/backends/postgis/base.py", line 126, in get_new_connection

    connection = super().get_new_connection(conn_params)

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

  File "/home/jajamionline/jajamionline-dir/env/lib/python3.12/site-packages/django/utils/asyncio.py", line 26, in inner

    return func(*args, **kwargs)

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

  File "/home/jajamionline/jajamionline-dir/env/lib/python3.12/site-packages/django/db/backends/postgresql/base.py", line 350, in get_new_connection

    connection = self.Database.connect(**conn_params)

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

  File "/home/jajamionline/jajamionline-dir/env/lib/python3.12/site-packages/psycopg2/__init__.py", line 122, in connect

    conn = _connect(dsn, connection_factory=connection_factory, **kwasync)

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

django.db.utils.OperationalError: connection to server at "localhost" (::1), port 5434 failed: Connection refused

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

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

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

IMG 1866 rathank.com Mohaiminul - Team Rathan 10/10/2024 12:10 pm

@waisalkindy If you follow the lessons carefully and still get this error, it could be due to a mistake in your database configuration. Please double-check your database information, such as what you have in the .env file, as any mistakes there could cause this error. Make sure all your database configuration details are correct.

cfb952218d2b0c4f1dd05632fb5fa2d3?s=36&d=mm&r=g rathank.com Alkindy Nur Zaman Wais Topic starter 10/10/2024 12:32 pm

Dear sir, thank you for your fast response..
except DEBUG=False, should all the data in 'sudo nano .env' on live server be same with local .env file?

cfb952218d2b0c4f1dd05632fb5fa2d3?s=36&d=mm&r=g rathank.com Alkindy Nur Zaman Wais Topic starter 10/10/2024 4:07 pm

Thank you so much sir,  this problem is now solved and I can proceed until the final video of the deployment and able to load all the static files and able to access my domain.. however I cannot login to my project using the live server even though the email address and password is correct.. do you know what is the problem sir? is there any step in postgres connection that need to be done to be able to login?

Share:

💥Diwali Festive Sale! Get Extra 30% OFF on All Courses!🎉
Use Code: DIWALI24

X