You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Ubuntu 20.04运行pgAdmin4遇重复列名OperationalError问题求助

Fix for "duplicate column name: hostaddr" Error When Launching pgAdmin4 on Ubuntu 20.04

Hey there, I’ve seen this exact issue a handful of times—it’s almost always down to leftover data from a previous pgAdmin4 installation conflicting with your new setup. Let’s break down what’s happening and how to fix it quickly:

What’s Causing the Error?

Your error log shows that pgAdmin4’s migration script is trying to add a hostaddr column to the server table in its SQLite config database (pgAdmin4.db), but that column already exists. This happens because you’re reusing the same ~/.pgAdmin/ directory from a prior install, where the database already has that column, but the new version’s migration doesn’t account for it.

Step-by-Step Fix

1. Kill any running pgAdmin4 processes first

Make sure no pgAdmin4 instances are holding onto the database file:

pkill -f pgadmin4.py

2. Backup your old config (optional but smart)

If you don’t want to lose your saved server connections, backup the old database before making changes:

mv ~/.pgAdmin/pgAdmin4.db ~/.pgAdmin/pgAdmin4.db.backup

3. Clear the conflicting database

You can either delete just the problematic database file:

rm ~/.pgAdmin/pgAdmin4.db

Or wipe the entire pgAdmin data directory if you don’t need any old settings:

rm -rf ~/.pgAdmin/

4. Reinitialize pgAdmin4

Head back to your virtualenv and rerun the pgAdmin4 startup script. It’ll create a fresh, clean database and run the migrations without conflicts:

cd pgadmin && source bin/activate
python /pgadmin/pgadmin/lib/python3.8/site-packages/pgadmin4/pgadmin4.py

Bonus: Restoring Old Connections (If You Backed Up)

If you saved the old database and want to get your connections back:

  1. Launch the new pgAdmin4 once to generate the fresh database structure
  2. Use a tool like sqlite3 to open both the old backup and new database
  3. Copy the rows from the old server table to the new one, making sure to omit the hostaddr column (since the new table already has it)

内容的提问来源于stack exchange,提问作者farhad.a

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.08 15:08:11