Fix for pgAdmin CSV import ‘Failed (exit code: -6)’ error (macOS)
This cryptic error takes the form of `Failed (exit code: -6)`. It usually pops up when importing csv files:
If you click on More details…, you receive another cryptic message:
"/Library/Postgres/12/bin/psql" — command" "\\copy public.table_name (col1, col2) FROM '/path/to/file.csv' DELIMITER ',' CSV HEADER QUOTE "\" ESCAPE ","
The Fix
As of the time of this article, the root cause here is an outdated pgAdmin version which comes by default with Postgres. Follow the steps below to update to the latest version:
- Close pgAdmin (if running)
- Download the latest pgAdmin
.dmg
file from https://www.pgadmin.org/download/pgadmin-4-macos/and open it. - Replace the existing
pgAdmin 4
in your Applications folder with thepgAdmin 4
extracted from the .dmg file above. (you can do this by dragging and dropping in the Applications folder) - Run pgAdmin and try importing the CSV files again.
This should resolve any errors at this point.
Still getting an error?
However, if you still get an error, there may be an issue with your file permissions. Hence, change the file permissions of the csv file you are trying to import with:
chmod 777 /path/to/file.csv
Note: changing file permissions to 777 can be dangerous so use this as a stopgap to make the program work. It is advisable to change permissions to be more restrictive later e.g. change it to one of 666, 766, 776
and see if the program still runs (lower = more secure).
Hope this helps!