PostgreSQL - OperationalError: could not connect to server: Is the server running on host "localhost" and accepting TCP/IP connections on port 5432?
Just run below command:
sudo chmod -R 700 /var/lib/postgresql/
PostgreSQL requires exclusive access to the files in the data directory. This is fixable depending on your operating system by using chmod 700 on the data directory or by right-clicking, and selecting various options on Windows.
Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!