Postgresql – Error connecting to the server:FATAL:couldnot open file“base\12135\11946”:No such file or directory

connectivitypostgresqlpostgresql-9.4

I have a issue from PostgreSQL 9.4 .The issue is given below:

An Error has occurred: Error connecting to the server:FATAL:could not
open file"base\12135\11946":No such file or directory.

This issue is in Windows 7.

Best Answer

A file in the base directory, where postgres stores it's data, is missing. This can be due to a corrupted filesystem or some program deleted the file.

At this point the first step you should do is to try and do a pg_dumpall. It will likely fail at the point where it encounters that missing file and then you will know what was impacted. Additionally, if you have other DBs besides the one impacted suggest you try to also back them up individually to make sure those other DBs don't have an issue.

After you identify what table(s) were impacted you then need to do one of these:

  • Restore the missing data from backups if you have them

  • If you don't have backups about the best you can do is to try and backup the individual object and see if you can get at least partially some of the data. The rest is likely lost.

  • After you have either deleted and restored, or just outright deleted, the table then do the backup of the impacted DB again to confirm if any other objects are also missing files.

  • Audit access to the server. Make sure nobody that should not have access has access.

  • Ask the people who have access to the server if they were doing any cleanups recently and they were deleting some files. Perhaps someone deleted the wrong file(s) by mistake and did not notice it.