XAMPP Errors on Mac OS X Mojave - macos

I am running MacOS Mojave 10.14 with XAMPP 7.2.5
Earlier today, I tried to start up XAMPP after a crash/restart. XAMPP Manager was unable to start the MYSQL Server. Apache did start correctly.
Figuring there was a potential corruption, I used my Time Machine to restore my XAMPP folder (to a 36-hour old file) in Applications.
Now when I try to run XAMPP Manager, I get a "Cannot find any readable ctl script" error message.
I've tried to run MYSQL Server directly from CLI. I receive the following message:
./mysql.server: line 200: my_print_defaults: command not found
Starting MariaDB
ERROR! Couldn't find MariaDB server (/Applications/XAMPP/xamppfiles/bin/mysqld_safe)
Any thoughts on how to resolve?

The issue has to do with a quirk with Time Machine - it does not completely regenerate all recorded folders/files. A bit of a pain.
I was able to run XAMPP from the command line:
-> cd /Applications/xampp/xamppfiles
-> sudo ./xampp start
To check on MYSQL status:
-> mysql status -u [username] -p [password]
Issue resolved

I spend a day on this and the solution in my case was:
Uninstall XAMPP
Delete all files except my databases folders from ⁨Applications/XAMPP⁩/xamppfiles/var⁩/mysql (there was some .err and log files if I remember well)
Reinstall XAMPP
Reconfigure it. If you use different user than root to access your databases you need to recreate it.

I got the "Cannot find any readable ctl script" error after a Time Machine restoration, too. I'm on 10.12.6 and XAMPP 5.6.
You are correct that it appears to be a TM issue, but I was able to resolve it by entering TM and specifically selecting the directories in XAMPP/xamppfiles/ that TM would not copy over by just selecting XAMPP/xamppfiles/. (In your case, you would not want to copy over /var/mysql, assuming you want to keep your data.)
Relief. There's nothing worse than realizing your trusty backup is not so trusty.

Related

XAMPP doesn't work after update to macOS Big Sur

Today I updated my mac to macOS Big Sur and I can't open XAMPP. When I click on app it doesn't give any response.
Do you know how solve this problem?
You can do a clean installation, but you will lose all your old files and databases. I suggest making a backup of this data.
Uninstall old versions of xampp.
Installation of Xampp by the brew
brew install --cask xampp
If you don't have the brew installed
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
HomeBrew
After Big Sur installation if XAMPP is not opening, get newest version of XAMPP (7.4.12) from their web site.
If you end up with error "Error starting “XAMPP” stack: cannot calculate MAC address: signal killed". After installing the latest version, do following:
Go to terminal ->
cd ~/.bitnami/stackman/helpers
Mv hyperkit hyperkit_backup
After that XAMPP opens and tells its the first time opening, but at least I found all the files etc as before Big Sur upgrade.
Install XAMPP 7.4.12, works perfectly in MacOS Big Sur
I had Xampp 7.4.9 and update Mac OS to Big Sur. Xampp didn't want to launch after that. I lost access to all my projects inside of /htdocs folder hidden somewhere in path structure of my virtual machine.
Kindly note I used version 7.4.9-VM (not 7.4.9-Installer) that is why all my files blocked inside of
/Users/'your_user_name'/.bitnami/stackman/machines/xampp/vm/machine.qcow2
Actually all files are important here:
/Users/'your_user_name'/.bitnami/stackman/machines/xampp
not only machine.qcow2
My solution is kind a mix of before mentioned solutions because they didn’t help in full.
First of all make a backup - copy old structure (with blocked files) to some directory - all this structure:
/Users/'your_user_name'/.bitnami/stackman/machines/xampp
(To see hidden files in MacOS use [Command]+[Shift]+[.])
You also can just rename
/Users/'your_user_name'/.bitnami/
to something like
/Users/'your_user_name'/.my_blocked_files_bitnami/
As programmers here advised to install 7.4.12-VM I installed this version. Very important to install "Virtual Machine" version (as you can see there are 2 installers for each version of Xampp)
Right after I launched 7.4.12-VM the new directory was created here:
/Users/'your_user_name'/.bitnami/
and Xampp will work properly but with no your old projects.
Do not do this step: As programmers here advised to change only one file
/Users/'your_user_name'/.bitnami/stackman/machines/xampp/vm/machine.qcow2
for me it was not enough - Xampp failed with an error:
ERROR: Error starting "XAMPP" stack: cannot start stack: ssh not accessible
My solution was put whole structure from folder xampp
/Users/'your_user_name'/.my_blocked_files_bitnami/stackman/machines/xampp
to here:
/Users/'your_user_name'/.bitnami/stackman/machines/xampp
You may before rename your current folder
/Users/'your_user_name'/.bitnami/stackman/machines/xampp
to something like
/Users/'your_user_name'/.bitnami/stackman/machines/new_xampp_without_my_projects
Then launch Xampp (Xampp should say something about incopatible versions but allows to continue), start all services, mount the disk. press "Expore" and you should see all your old projects.
Thank you.
You can solve this problem by updating xampp ver 7.2.34 .
https://www.apachefriends.org/download.html
Same thing happened to me but the version 7.4.12 seems to be working. I download it from the link I'll but below. I've been reading and the problem seems to be that Big Sur changes some paths that are set by default and so the apps won't launch. Same thing happened to Apache NetBeans.
XAMPP Download Link:
(https://sourceforge.net/projects/xampp/files/XAMPP%20Mac%20OS%20X/7.4.12/)
I had the same problem. This is how I solved it:
First, be sure that you back up your files in XAMPP VM. Your files are in
/Users/'your_user_name'/.bitnami/stackman/machines/xampp/vm/machine.qcow2
Then you can reinstall XAMPP again. I have installed 7.4.12 and it worked fine.
If you see stack error message, this is what you have to do:
Close XAMPP
Open a terminal and remove the stack folder with the following code:
rm -rf ~/.bitnami/stackman
Open XAMPP and check if a new stackman folder is created.
/Users/'your_user_name'/.bitnami/stackman/
If it does not, then start XAPP and stop again. When the stackman folder is created, override the file below with your backup file.
/Users/'your_user_name'/.bitnami/stackman/machines/xampp/vm/machine.qcow2
Close XAMPP again and restart again.
Voila! Here are your files...
I tried reinstalling XAMPP on MACos Big Sur, and it worked. However, my files are not recovered.
you can type this code in terminal
before this code you should close xampp
rm -rf ~/.bitnami/stackman
if you are getting error message saying:
Cannot calculate MAC Address: Using fd 10 for I/O notifications hv_vm_create HV_ERROR (unspecified error)
you need to download new hyperkit from bitnami and replace the current one
cd /tmp
curl -LJO "https://downloads.bitnami.com/files/hyperkit/hyperkit-testing-`20210430"`
mv /tmp/hyperkit-testing-20210430 ~/.bitnami/stackman/helpers/hyperkit
chmod +x ~/.bitnami/stackman/helpers/hyperkit
read tutorial here:
https://floyk.com/en/post/xampp-doesnt-work-after-update-to-macos-big-sur

Could not get PostgreSQL 11.2 to start. Tried deleting everything, and now PostgreSQL 11.2 Refuses to install with an error

I tried installing PostgreSQL 11.2 on Windows through this link: https://www.openscg.com/bigsql/postgresql/installers.jsp/
but the program would not start no matter what I tried. A quick black window would appear for a tenth of a second, disappear, and then absolutely nothing would happen.
Thus, I uninstalled it and deleted the directory and tried to install PostgreSQL 11.2 on Windows through this link:
https://www.enterprisedb.com/downloads/postgres-postgresql-downloads
It installed properly, but when I opened my file explorer to C: where the directory should have been installed I was given an error "PostgreSQL could not be found". I thought my previous installation was causing issues, so I did a 'Search Local C:' in file explorer and found over 9,000 files involving PostgreSQL. I 'Ctrl+A' deleted all of them and skipped the exceptions saying 'You need permission to delete this file', 'This file is in use', 'Unable to locate file', etc.
I then tried to reinstall PostgreSQL 11.2 via this link (same as second link):
https://www.enterprisedb.com/downloads/postgres-postgresql-downloads
However, after saying yes to 'permission to make changes on this computer', I immediately get the error box "There has been an error. Error reading file C;/Program Files/PostgreSQL/11/data/postgresql.conf", and I can no longer install PostgreSQL.
How do I fix this?
Thank you to Mike from the comments. Here is what I did:
1) I found all the old PostgreSQL stuff, including the program files directory tree, and deleted all of it using the uninstall function when I could.
2) Next, I reset my postgresql system environment variables and restarted my computer.
3) I deleted all top level directories for PostgreSQL and downloaded the PostgreSQL distributed by postgresql.org. I was finally able to install PostgreSQL again.
4) PGAdmin4 works, and if I use the command line type 'cmd.exe /c chcp 1252' and then type something like 'psql -U postgres postgres" and enter your password.

Not able to cache templates and will be slow because of this notice

Recently bought a Macbook Pro with macOS Sierra and installed XAMPP version 7.0.31.
After turning on MYSQL, ProFTPD and Apache Web Server, I noticed something when I opened phpmyadmin.
There was an error below saying:
The $cfg['TempDir'] (./tmp/) is not accessible. phpMyAdmin is not able to cache templates and will be slow because of this.
Probably, do you get an error like this?
The Solution Process:
First, stop xampp service; /opt/lampp/lampp stop
Then, Go to the installation director of phymyadmin then find its "config.inc.php" file then add $cfg['TempDir'] = '/tmp'; like this
At the end, start xampp service /opt/lampp/lampp start

Error starting "XAMPP" stack: cannot calculate MAC address: signal killed

I recently installed XAMPP-VM on my Mac. I am encountering a problem whenever I click Start in the General tab. Log tab shows that...
INFO: Starting "XAMPP" stack
ERROR: Error starting "XAMPP" stack: cannot calculate MAC address: signal: killed
As an individual who is not knowledgeable of such error, could someone explain what this error means and how to fix it?
I had the same problem and fixed it.
You have to close xampp, then type on your terminal:
rm -rf ~/.bitnami/stackman
And open xampp again.
Hope it works for you :) .
Make sure you have these requirements to use XAMPP-VM platform:
OS X 10.10.3 Yosemite or later
a 2010 or later Mac (i.e. a CPU that supports EPT)
UPDATE:
Unfortunately you can not use XAMPP-VM if you don't have this requirements but you can use the regular OS X native installer available at https://www.apachefriends.org/download.html
For people using Apple silicon chips, using installer.dmg instead of vm.dmg works.
For example, I used the following link for version 8.4.1:
https://sourceforge.net/projects/xampp/files/XAMPP%20Mac%20OS%20X/8.1.4/xampp-osx-8.1.4-0-installer.dmg/download
Hitting the same error. However, I pressed start after a while it works. lol...
Running Mac OS 10.12.6 (16G29) and XAMPP 7.2.0
Anyone is still facing the issue of macOS Big Sur. Below I have attached few commands please follow the same.
Important: Make sure to take the backup of the working projects manually.
#create a backup of your contents inside htdocs
cp -rp ~/.bitnami ~/.bitnami.back
#note: this command enters tmp folder if you are in Users/ directory
cd ../../tmp
#installs hyper kit
curl -LJO "https://downloads.bitnami.com/files/hyperkit/hyperkit-testing-20210430"
#Check the hash
md5 /tmp/hyperkit-testing-20210430
#move the hyper kit
mv /tmp/hyperkit-testing-20210430 ~/.bitnami/stackman/helpers/hyperkit
#give permission for hyper kit
chmod +x ~/.bitnami/stackman/helpers/hyperkit
Also I have attached the video link: https://www.youtube.com/watch?v=FfQHNQTj28c
Another solution for Big Sur (probably works up to, but not including, Ventura) if you are trying to get the contents of your VM working as well.
Rename the current .bitnami/stackman folder to something else like stackman_old
Open up the Bitnami VM and it should rebuild the stackman folder and reassign a new localhost IP address.
Make sure that VM works by starting it up and checking it's all green
If good, quit the VM again
Move the stackman_old/machines/xampp/ssh folder into the same place into the new stackman folder.
Move the stackman_old/machines/xampp/vm folder into the same place into the new stackman folder.
After doing these two folder replacements, open up the VM again and it should start up fine, just will have the new IP address so if you are referencing that ip in your etc/hosts file, you'll have to update those so it's pointing to the right place.
Hopefully this helps someone!

psql: could not connect to server: No such file or directory (Mac OS X)

Upon restarting my Mac I got the dreaded Postgres error:
psql: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
The reason this happened is because my macbook froze completely due to an unrelated issue and I had to do a hard reboot using the power button. After rebooting I couldn't start Postgres because of this error.
WARNING: If you delete postmaster.pid without making sure there are really no postgres processes running you, could permanently corrupt your database. (PostgreSQL should delete it automatically if the postmaster has exited.).
SOLUTION: This fixed the issue--I deleted this file, and then everything worked!
/usr/local/var/postgres/postmaster.pid
--
and here is how I figured out why this needed to be deleted.
I used the following command to see if there were any PG processes running. for me there were none, I couldn't even start the PG server:
ps auxw | grep post
I searched for the file .s.PGSQL.5432 that was in the error message above. i used the following command:
sudo find / -name .s.PGSQL.5432 -ls
this didn't show anything after searching my whole computer so the file didn't exist, but obviously psql "wanted it to" or "thought it was there".
I took a look at my server logs and saw the following error:
cat /usr/local/var/postgres/server.log
at the end of the server log I see the following error:
FATAL: pre-existing shared memory block (key 5432001, ID 65538) is still in use
HINT: If you're sure there are no old server processes still running, remove the shared memory block or just delete the file "postmaster.pid".
Following the advice in the error message, I deleted the postmaster.pid file in the same directory as server.log. This resolved the issue and I was able to restart.
So, it seems that my macbook freezing and being hard-rebooted caused Postgres to think that it's processes were still running even after reboot. Deleting this file resolved. Lots of people have similar issues but most the answers had to do with file permissions, whereas in my case things were different.
None of the above worked for me. I had to reinstall Postgres the following way :
Uninstall postgresql with brew : brew uninstall postgresql
brew doctor (fix whatever is here)
brew cleanup
Remove all Postgres folders :
rm -r /usr/local/var/postgres
rm -r ~/Library/Application\ Support/Postgres
Reinstall postgresql with brew : brew install postgresql
Start server : brew services start postgresql
You should now have to create your databases... (createdb)
If you're on macOS and installed postgres via homebrew, try restarting it with
brew services restart postgresql
If you're on Ubuntu, you can restart it with either one of these commands
sudo service postgresql restart
sudo /etc/init.d/postgresql restart
Maybe this is unrelated but a similar error appears when you upgrade postgres to a major version using brew; using brew info postgresql found out this that helped:
To migrate existing data from a previous major version of PostgreSQL run:
brew postgresql-upgrade-database
Here is my way:
launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
rm /usr/local/var/postgres/postmaster.pid
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
The following commands helped me out. The issue was with the PostgreSQL data version. Once upgraded, it started working fine for me.
brew upgrade postgresql
brew postgresql-upgrade-database
brew services restart postgresql
if your postmaster.pid is gone and you can't restart or anything, do this:
pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start
as explained here initially
For me, the solution was simply restart my computer. I first tried restarting with Brew services and when that didn't work, restarting seemed like the next best option to try before looking into some of the more involved solutions. Everything worked as it should after.
Another class of reasons why this can happen is due to Postgres version updates.
You can confirm this is a problem by looking at the postgres logs:
tail -n 10000 /usr/local/var/log/postgres.log
and seeing entries like:
DETAIL: The data directory was initialized by PostgreSQL version 12, which is not compatible with this version 13.0.
In this case (assuming you are on Mac and using brew), just run:
brew postgresql-upgrade-database
(Oddly, it failed on run 1 and worked on run 2, so try it twice before giving up)
Hello world :)The best but strange way for me was to do next things.
1) Download postgres93.app or other version. Add this app into /Applications/ folder.
2) Add a row (command) into the file .bash_profile (which is in my home directory):
export PATH=/Applications/Postgres93.app/Contents/MacOS/bin/:$PATH
It's a PATH to psql from Postgres93.app. The row (command) runs every time console is started.
3) Launch Postgres93.app from /Applications/ folder. It starts a local server (port is "5432" and host is "localhost").
4) After all of this manipulations I was glad to run $ createuser -SRDP user_name and other commands and to see that it worked! Postgres93.app can be made to run every time your system starts.
5) Also if you wanna see your databases graphically you should install PG Commander.app. It's good way to see your postgres DB as pretty data-tables
Of, course, it's helpful only for local server. I will be glad if this instructions help others who has faced with this problem.
This problema has many sources, and thus many answers. I've experienced each one of them.
1) If you have a crash of some sort, removing the /usr/local/var/postgres/postmaster.pid file is probably required as postgres may not have handled it properly. But ensure that no process is running.
2) Craig Ringer has pointed out in other posts that Apple's bundling of postgreSQL leads to pg gem installation issues Setting the PATH environment variable is a solution.
3) Another solution, is to uninstall and reinstall the gem. A brew update may be necessary as well.
If you stumble upon this post, if you can pinpoint one of the sources, you'll save time...
I was facing a similar issue here I solved this issue as below.
Actually the postgres process is dead, to see the status of postgres run the following command
sudo /etc/init.d/postgres status
It will says the process is dead`just start the process
sudo /etc/init.d/postgres start
This happened to me after my Mac (High Sierra) froze and I had to manually restart it (press and hold the power button). All I had to do to fix it was do a clean restart.
I had the same issue.
Most of the times, the problem is the fact that there's a leftover file
/usr/local/var/postgres/postmaster.pid
which works for most people, but my case was different - I tried googling this issue for last 3 hours, uninstalled postresql on OSX through brew, purged the database, nothing worked.
Finally, I noticed that I had an issue with brew that whenever I tried to install anything, it popped:
Error: Permission denied # rb_sysopen - /private/tmp/github_api_....
or something like it at the end of an install.
I simply did sudo chmod -R 777 /private/tmp and it finally works!
I'm writing this down because this might be a solution for someone else
I faced the same problem for psql (PostgreSQL) 9.6.11.
what worked for me -
remove postmaster.pid -- rm /usr/local/var/postgresql#9.6/postmaster.pid
restart postgres -- brew services restart postgresql#9.6
If postmaster.pid doesn't exist or the above process doesn't work then run --
sudo chmod 700 /usr/local/var/postgresql#9.6
For those running into this issue on M1 macs, try deleting this file and then restarting the brew service:
rm /opt/homebrew/var/postgres/postmaster.pid
My problem ended up being that I was using Gas Mask (a hosts file manager for Mac), and I didn't have an entry for localhost in the hosts file I was using.
I added:
127.0.0.1 localhost
And that resolved my problem.
I'm not entirely sure why, but my Postgres installation got a little bit screwed and some files were deleted resulting in the error OP is showing.
Despite the fact that I am able to run commands like brew service retart postgres and see the proper messages, this error persisted.
I went through the postgres documentation and found that my file /usr/local/var/postgres was totally empty. So I ran the following:
initdb /usr/local/var/postgres
It seems some configurations took place with that command.
Then it asked me to run this:
postgres -D /usr/local/var/postgres
And that told me a postmaster.pid file already exists.
I just needed to know if brew would be able to pick up the configs I just ran, so I tested it out.
ls /usr/local/var/postgres
That showed me a postmaster.pid file. I then did brew services stop postgresql, and the postmaster.pid file disappeared. Then I did brew services start postgresql, and VIOLA, the file reappeared.
Then I went ahead and ran my app, which did in fact find the server, however my databases seem to be gone.
Although I know that they may not be gone at all - the new initialization I did may have created a new data_area, and the old one isn't being pointed to. I'd have to look at where that's at and point it back over or just create my databases again.
Hope this helps! Reading the postgres docs helped me a lot. I hate reading answers that are like "Paste this in it works!" because I don't know what the hell is happening and why.
I had the same issue and it was due to an incompatible version after upgrading from version 11 to 13.2
Checking error log at:
/usr/local/var/log/postgres.log
Showed me:
DETAIL: The data directory was initialized by PostgreSQL version 11, which is not compatible with this version 13.2.
To fix I ran:
brew postgresql-upgrade-database
And then started postresql with brew:
brew services start postgresql
The causes of this error are many so first locate your log file and check it for clues. It might be at /usr/local/var/log/postgres.log or /usr/local/var/postgres/server.log or possibly elsewhere. If you installed with Homebrew you can find the location in ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist.
I had this same concern when connecting trying to start a PostgreSQL database server on MacOS Monterey.
When I run the command below to restart the PostgreSQL database server:
brew services restart PostgreSQL
It restarts but when I try to check the status of the PostgreSQL database server using the command below, I get an error:
Name Status User File
mysql started promisepreston ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
nginx started promisepreston ~/Library/LaunchAgents/homebrew.mxcl.nginx.plist
postgresql error 256 root ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
Here's what worked for me:
First, I checked the log file for the PostgreSQL database server to what was the cause of the error using the command below:
cat /usr/local/var/log/postgres.log
OR
nano /usr/local/var/log/postgres.log
The logs showed the following errors:
"root" execution of the PostgreSQL server is not permitted.
The server must be started under an unprivileged user ID to prevent
possible system security compromise. See the documentation for
more information on how to properly start the server.
2022-01-25 19:01:06.051 WAT [29053] FATAL: database files are incompatible with server
2022-01-25 19:01:06.051 WAT [29053] DETAIL: The data directory was initialized by PostgreSQL version 13, which is not compatible with this version 14.1.
For the root execution error I had to run the following command to fix file permissions that when messed us when I ran brew services with the sudo command prefix. Replace your-username with your MacOS username (in my case my username was promisepreston:
# Stop postgresql
sudo brew services stop PostgreSQL
# In case service file is copied to ~/Library/LaunchAgents as well
brew services stop postgresql
# Fix permission of homebrew files
sudo chown -R your-username:admin $(brew --prefix)/*
For the database files are incompatible with server I had to simply upgrade the existing PostgreSQL data files which were created using version 13 to the latest PostgreSQL version on my computer which was 14.1 by running the following command below:
brew postgresql-upgrade-database
Afterwhich, I restarted the PostgreSQL database server:
brew services restart PostgreSQL
And then checked the status using the command below:
brew services list
Then I got the output below showing that everything was working fine:
Name Status User File
mysql started promisepreston ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
nginx started promisepreston ~/Library/LaunchAgents/homebrew.mxcl.nginx.plist
postgresql started promisepreston ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
References: Brew PostgreSQL Starts But Process Is Not Running
I had a similar error.
All of this is done from the command line (no sudo calls at all)
I verified I had PostgreSQL installed psql -V (note that's a capital "V")
I attempted to connect to the server: psql postgres
THIS IS WHERE I EXPERIENCED THE ERROR OF THIS STACK OVERFLOW QUESTION
After doing some research about possible fixes, I obviously had PostgreSQL installed, but I didn't have a default server in place.
What I had to do was create a Custom Data Directory
As far as I can tell, creating the custom data directory is the same as having a default server in place.
Since this is a new machine (MacBook Pro 2021 using apple m1 chip), I wanted to find the easiest solution possible, and I believe this Custom Data Directory is just that. The remaining steps to fix this issue are as follows:
From the home directory, I created an empty directory mkdir myData
From the home directory, Initialized a server: initdb myData (throws a bunch of files into the myData directory)
pg_ctl -D myData -l logfile start (starts the server)
psql postgres (connects to the server)
So, as someone fairly new to PostgreSQL and databases and SQL in general, couple notes:
It is possible to "quit" the connection to the server, using \q (while connected to the server, it's also possible to type "help")
It is also possible to "stop" the server, as well with pg_ctl -D myData stop
At this point I now am certain I have PostgreSQL installed, have a server I can start and stop, and have the ability to connect to/disconnect from, that server.
Go to /var/log/
and run cat postgres.log
Here you will find the reason for the failure of postgres.
If it is a smart shut down then probably your icu4c version (C++ library for Unicode) is not proper which is linked with postgres. So run the following commands.
brew upgrade
brew cleanup
This should work ;)
I've had to look up this post several times to solve this issue. There's another fix, which will also applies to similar issues with other running programs.
I just discovered you can use the following two commands.
$top
This will show all the currently running actions with their pid numbers. When you find postgres and the associated pid
$kill pid_number
I just got the same issue as I have put my machine(ubuntu) for update and got below error:
could not connect to server: No such file or directory Is the server
running locally and accepting connections on Unix domain socket
"/var/run/postgresql/.s.PGSQL.5432"?
After completing the updating process when I restart my system error gone. And its work like charm as before.. I guess this was happened as pg was updating and another process started.
SUPER NEWBIE ALERT: I'm just learning web development and the particular tutorial I was following mentioned I have to install Postgres but didn't actually mention I have to run it as well... Once I opened the Postgres application everything was fine and dandy.
#Jagdish Barabari's answer gave me the clue I needed to resolve this. Turns out there were two versions of postgresql installed while only one was running. Purging all postgresql files and reinstalling the latest version resolved this issue for me.
I removed /usr/lib from the LD_LIBRARY_PATH and it worked.
I was working in dockerfile postgres:alpine.
This answer worked for me: https://stackoverflow.com/a/45454567/15067545 on my ubuntu system.
Command: sudo service postgresql restart.

Resources