Continue reading the post to figure out the solutions to handle the error warning. We will help you drag out the error so that you can get through the code. Check out how the error arises
How do you get the error?
You may have tried to download Portainer on your server, and then create a Postgres container for the database. When you tried to access that database, you get the error warning appears. You get the following error shows up in the log
2021-10-08  FATAL: database files are incompatible with server
2021-10-08  DETAIL: The data directory was initialized by PostgreSQL version 13, which is not compatible with this version 14.0 (Debian 14.0-1.pgdg110+1).
PostgreSQL Database directory appears to contain a database; Skipping initialization
Ways To Resolve the Error “the data directory was initialized by PostgreSQL version 13 which is not compatible with this version 14.0”
Solution 1 – Redraw the Image
To sort the error message, you need to draw a PostgreSQL image. To do that, you need to follow the below procedure
- Delete the Postgres image you have
- Next, you need to delete the volume
- In the last step, you simply need to pull the image again
You can use the below command
docker kill $(docker ps -q) # stop all containers
docker rm $(docker ps -a -q) # remove all containers
docker rmi $(docker images -q) # remove all images
docker network prune # remove all networks
docker volume prune # remove all volumes
Solution 2 – Upgrade the data file to the new format
Another solution to fix the error, you need to upgrade the data file to a new format. You can simply do that by following this command:
$ brew postgresql-upgrade-database
Solution 3 – Downgrade Postgres to 13 version
Sometimes the problem is with the version you are using for creating particular projects. So, downgrading is one of the effective ways to get rid of the error. you can downgrade it to version 13 to resolve the error.
We discussed the solutions to tackle the error “the data directory was initialized by PostgreSQL version 13 which is not compatible with this version 14.0”. I hope you find it helpful.
I wish you all the best!