Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

PostgreSQL Error 22023: Invalid Parameter Value Fix Guide

· 5 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

PostgreSQL error 22023 occurs when a configuration parameter is set to a value that is not accepted by the server. This is not a syntax error or a connection issue—it means you're trying to use a valid parameter name with an invalid value, such as setting 'log_min_duration_statement' to a negative number or 'max_connections' to a value exceeding system limits. The error is precise and actionable: you must correct the parameter value in your configuration file or session. No external tools or restarts are needed to diagnose it, but a server reload or restart may be required to apply changes.

What You'll Need

  • Access to the PostgreSQL server (via command line, SSH, or local terminal)
  • Permissions to edit PostgreSQL configuration files (typically requires superuser or root access)
  • Knowledge of which parameter caused the error (found in the error log or client message)
  • A text editor (like nano, vim, or Notepad++)
  • Optional: The output of SHOW all; to review current valid settings

Step-by-Step

  1. Locate the PostgreSQL configuration file. The main file is usually postgresql.conf. Find its location by running SHOW config_file; in psql or via the command line with pg_config --config-file. Common paths include /etc/postgresql/[version]/main/postgresql.conf on Ubuntu or C:\Program Files\PostgreSQL\[version]\data\postgresql.conf on Windows.
  2. Open the configuration file in a text editor with appropriate permissions. On Linux/macOS, use sudo nano /etc/postgresql/[version]/main/postgresql.conf. On Windows, right-click the file and open with Notepad as Administrator.
  3. Search for the parameter mentioned in the error message. PostgreSQL logs the exact parameter name in the error, such as invalid value for parameter "log_min_duration_statement": "-1". Use Ctrl+F (or Cmd+F) to find the parameter name in the file.
  4. Check the valid range for that parameter. For example, log_min_duration_statement accepts 0 or positive integers (milliseconds); negative values are invalid. max_connections must be between 1 and the system limit (usually 100–1000 depending on OS and memory). Refer to the official PostgreSQL documentation for your version if unsure.
  5. Correct the value. If it's set to log_min_duration_statement = -1, change it to log_min_duration_statement = 0 or another valid number. If it's max_connections = 2000 and your system only supports 500, reduce it to max_connections = 500.
  6. Save the file and exit the editor. Do not rename or move the file—only edit its contents.
  7. Reload the PostgreSQL configuration without restarting the server. In psql, run SELECT pg_reload_conf();. Alternatively, use the command line: sudo pg_ctl reload on Linux or pg_ctl reload -D "C:\Program Files\PostgreSQL\[version]\data" on Windows.
  8. Verify the change took effect by running SHOW log_min_duration_statement; or SHOW max_connections; in psql. The output should reflect your new value.
  9. If the error persists after reload, restart the PostgreSQL service. Use sudo systemctl restart postgresql on Linux, or restart the service via Windows Services (search for "PostgreSQL" in Services.msc).

Common Mistakes

  • Editing the wrong configuration file—some systems have multiple instances (e.g., multiple PostgreSQL versions installed). Always confirm the path using SHOW config_file;.
  • Typing the parameter name incorrectly—parameter names are case-insensitive, but misspelling (e.g., max_connectons) will be ignored and not cause an error, delaying diagnosis.
  • Setting string parameters as numbers—e.g., ssl = "on" is correct, but ssl = 1 is invalid.
  • Using commas in numeric values—max_connections = 1,000 is invalid; use 1000.
  • Forgetting to reload or restart—changing the file alone doesn't apply the setting. Always run pg_reload_conf() or restart the service.

Tips

  • Always backup postgresql.conf before editing: cp postgresql.conf postgresql.conf.bak.
  • Use SHOW all; in psql to see all current settings and their valid formats. This helps you understand acceptable syntax.
  • For dynamic parameters (like shared_buffers), changes require a full restart—even if pg_reload_conf() runs successfully.
  • Set parameters in the correct scope: some only work in postgresql.conf, others can be set per session with SET. Check the "Context" column in PostgreSQL’s parameter documentation.
  • If you're unsure of a value's validity, start with the default. Defaults are always safe and documented.
  • Use comments in the config file to note why a value was changed (e.g., # Increased from 100 to 500 to support application pool size — 2024-06-01).

Troubleshooting

If the error persists after following the steps above, first check the PostgreSQL server log file (usually in the log_directory path, found via SHOW log_directory;). Look for lines containing "invalid parameter value"—they may reveal additional context or secondary errors. If the server fails to start after a restart, the configuration file likely contains a syntax error. Try renaming the current postgresql.conf to postgresql.conf.bad and restarting. PostgreSQL will generate a new default file, allowing you to compare and reapply your changes incrementally. If you are using a cloud-managed PostgreSQL service (like AWS RDS or Google Cloud SQL), you cannot edit postgresql.conf directly. Instead, modify the parameter group or instance settings via the cloud console. For parameter groups, ensure the value is within allowed ranges for your instance class—some cloud providers cap max_connections based on memory. If you're using an ORM or application framework that sets parameters dynamically (e.g., via SET statements), check your application code for hard-coded values. For example, a Django app might set SET statement_timeout = -1; change that to a valid positive integer. If all else fails, temporarily comment out the problematic line in postgresql.conf and restart to confirm the server loads without it, then re-add the parameter with a known-good value.

Frequently Asked Questions

What does error 22023 mean in PostgreSQL?

It means a configuration parameter was assigned a value that is not allowed by the server—like a negative number for a timer or a string where a number is expected.

Can I fix this without restarting the server?

Yes, for most parameters, use SELECT pg_reload_conf(); after editing the config file. Only parameters marked as "SIGHUP" or "postmaster" require a restart.

Why does my parameter value work in one database but not another?

Each PostgreSQL instance has its own postgresql.conf. If you're connecting to multiple servers, you may have edited the wrong one. Always confirm which server you're connected to with SELECT version();.

Is there a list of all valid parameter values?

Yes. The official PostgreSQL documentation lists each parameter with its allowed types, ranges, and default values. Search for "PostgreSQL [version] configuration settings" in your browser.

Can I set parameters using SQL instead of editing the config file?

Yes, for many parameters, use SET parameter_name = value; in a session. But these changes only last until the session ends. To make them permanent, you must edit postgresql.conf.

What if I don't know which parameter is causing the error?

Check your application logs, PostgreSQL server logs, or psql output. The error message always includes the parameter name. If it's not visible, run SHOW all; and look for unusual values.