pg_dump: error: connection to database "inventree" failed: could not connect to server

This issue has been tracked since 2023-01-09.

Deployment Method

  • Installer
  • Docker Development
  • Docker Production
  • Bare metal Development
  • Bare metal Production
  • Digital Ocean image
  • Other (please provide a link Steps to Reproduce

Describe the problem*

pg_dump: error: connection to database "inventree" failed: could not connect to server: Connection timed out
Is the server running on host "172.17.0.3" and accepting
TCP/IP connections on port 5432?

Steps to Reproduce

  1. Added in pg_hba.conf the following
    host all all 172.50.0.0/16 trust
    host all all 172.50.0.2/16 trust
    host all all 172.26.0.0/16 trust
    host all all 172.19.0.0/16 trust
  2. ran "docker restart postgresql"
  3. Followed steps here https://docs.inventree.org/en/latest/start/docker_prod/

Relevant log output

Backing up InvenTree database...
Backing Up Database: inventree
CommandConnectorError: Error running:  pg_dump --dbname=postgresql://inventree_user:**********@172.17.0.3:5432/inventree --format=custom 
pg_dump: error: connection to database "inventree" failed: could not connect to server: Connection timed out
	Is the server running on host "172.17.0.3" and accepting
	TCP/IP connections on port 5432?

  File "/root/.local/lib/python3.9/site-packages/dbbackup/utils.py", line 120, in wrapper
    func(*args, **kwargs)
  File "/root/.local/lib/python3.9/site-packages/dbbackup/management/commands/dbbackup.py", line 93, in handle
    self._save_new_backup(database)
  File "/root/.local/lib/python3.9/site-packages/dbbackup/management/commands/dbbackup.py", line 106, in _save_new_backup
    outputfile = self.connector.create_dump()
  File "/root/.local/lib/python3.9/site-packages/dbbackup/db/base.py", line 92, in create_dump
    return self._create_dump()
  File "/root/.local/lib/python3.9/site-packages/dbbackup/db/postgresql.py", line 112, in _create_dump
    stdout, stderr = self.run_command(cmd, env=self.dump_env)
  File "/root/.local/lib/python3.9/site-packages/dbbackup/db/base.py", line 171, in run_command
    raise exceptions.CommandConnectorError(

Traceback (most recent call last):
  File "/home/inventree/InvenTree/manage.py", line 23, in <module>
    execute_from_command_line(sys.argv)
  File "/root/.local/lib/python3.9/site-packages/django/core/management/__init__.py", line 419, in execute_from_command_line
    utility.execute()
  File "/root/.local/lib/python3.9/site-packages/django/core/management/__init__.py", line 413, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/root/.local/lib/python3.9/site-packages/django/core/management/base.py", line 354, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/root/.local/lib/python3.9/site-packages/django/core/management/base.py", line 398, in execute
    output = self.handle(*args, **options)
  File "/root/.local/lib/python3.9/site-packages/dbbackup/utils.py", line 120, in wrapper
    func(*args, **kwargs)
  File "/root/.local/lib/python3.9/site-packages/dbbackup/management/commands/dbbackup.py", line 93, in handle
    self._save_new_backup(database)
  File "/root/.local/lib/python3.9/site-packages/dbbackup/management/commands/dbbackup.py", line 106, in _save_new_backup
    outputfile = self.connector.create_dump()
  File "/root/.local/lib/python3.9/site-packages/dbbackup/db/base.py", line 92, in create_dump
    return self._create_dump()
  File "/root/.local/lib/python3.9/site-packages/dbbackup/db/postgresql.py", line 112, in _create_dump
    stdout, stderr = self.run_command(cmd, env=self.dump_env)
  File "/root/.local/lib/python3.9/site-packages/dbbackup/db/base.py", line 171, in run_command
    raise exceptions.CommandConnectorError(
dbbackup.db.exceptions.CommandConnectorError: Error running:  pg_dump --dbname=postgresql://inventree_user:**********@172.17.0.3:5432/inventree --format=custom 
pg_dump: error: connection to database "inventree" failed: could not connect to server: Connection timed out
	Is the server running on host "172.17.0.3" and accepting
	TCP/IP connections on port 5432?
matmair wrote this answer on 2023-01-11

@quezon

  1. are you using the installer or docker?
  2. did you check if you can connect to pgsql manually?
  3. which version of pgsql are you running?
quezon wrote this answer on 2023-01-13

I am running PostgreSQL 15.1 (Debian 15.1-1.pgdg110+1) on aarch64-unknown-linux-gnu, compiled by gcc (Debian
10.2.1-6) 10.2.1 20210110, 64-bit
. I am using Docker. Yes I can connect to Postgres using psql in the Ubuntu terminal.

matmair wrote this answer on 2023-01-13

@quezon do you have backups enabled? I think this is related to the backup component - which ships with an old version of pgdump.

quezon wrote this answer on 2023-01-23

I am not sure. Is there a way to find out? I tried to find the information by googling but couldn't find it. Let me know how to find out whether it's backup enabled and I will let you know.

matmair wrote this answer on 2023-01-23

@quezon there is a switch in the config file and you would be able to activate it in the webinterface.

matmair wrote this answer on 2023-02-13

Closing due to inactivity. Please reopen if the problem is still persisting.

More Details About Repo
Owner Name inventree
Repo Name InvenTree
Full Name inventree/InvenTree
Language Python
Created Date 2017-03-23
Updated Date 2023-03-31
Star Count 2586
Watcher Count 61
Fork Count 411
Issue Count 141

YOU MAY BE INTERESTED

Issue Title Created Date Updated Date