Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 508 Vote(s) - 3.55 Average
  • 1
  • 2
  • 3
  • 4
  • 5
PG::ConnectionBad - could not connect to server: Connection refused

#31
For MacOS I use this:
```
brew info postgres
```
And in output in the most end, I see:
```
...
To have launchd start postgresql now and restart at login:
brew services start postgresql
Or, if you don't want/need a background service you can just run:
pg_ctl -D /usr/local/var/postgres start
```

So I just use this command `pg_ctl -D /usr/local/var/postgres start
` and `psql` begin work.
Reply

#32
If removing `postmaster.pid` does not resolve the issue, this worked for me:

cd /usr/local/var/
rm -rf postgres/
mkdir postgres
initdb --locale=C -E UTF-8 postgres/
brew services restart postgresql

Credit to @spirito_libero 's solution on [this thread][1].


[1]:

[To see links please register here]

Reply

#33
For me, it was really simple: I had a stale `postmaster.pid` file.

Simply deleting and restarting postgres fixed it for me:

```
rm '/Users/<username>/Library/Application Support/Postgres/var-10/postmaster.pid'
```
Reply

#34
This occurred for me after upgrade Postgres (through Homebrew). I upgraded from version 12 to 13.

If this is the case for you try running `postgres -D /usr/local/var/postgres` and check the output. In my case it stated `database files are incompatible with server`.

You might get an error message that postgres.old already exists
```
Error: /usr/local/var/postgres.old already exists!
```

To fix that, just remove that file
```
rm -rf /usr/local/var/postgres.old
```

Fixing the database was as simple as running:
```
brew postgresql-upgrade-database
```
Reply

#35
I have tried all of the answers above and it didn't work for me.

In my case when I chekced the log on `/usr/local/var/log/postgres.log`. It was fine no error. But I could see that it was listening my local IPV6 address which is `"::1"`

In my `database.yml` It was like this

```
host: <%= ENV['POSTGRESQL_ADDON_HOST'] || '127.0.0.1' %>
```

I changed it by


```
host: <%= ENV['POSTGRESQL_ADDON_HOST'] || 'localhost' %>
```

and then it worked
Reply

#36
It could be as simple as a stale **PID file**. It could be failing silently because your computer didn't complete the shutdown process completely which means **postgres** didn't delete the **PID** (process id) file.

The PID file is used by postgres to make sure only one instance of the server is running at a time. So when it goes to start again, it fails because there is already a **PID** file which tells **postgres** that another instance of the server was started (even though it isn't running, it just didn't get to shutdown and delete the PID).

1. To fix it remove/rename the PID file. Find the postgres data directory. On macOS using homebrew it is in `/usr/local/var/postgres/`,
or `/usr/local/var/log/` other systems it might be `/usr/var/postgres/`. On M1, it might be `/opt/homebrew/var/postgresql`.
1. To make sure this is the problem, look at the log file (`server.log`). On the last lines you will see:

>FATAL: lock file "postmaster.pid" already exists<br>
>HINT: Is another postmaster (PID 347) running in data directory "/usr/local/var/postgres"?

3. If so, `rm postmaster.pid`
1. Restart your server. On a mac using launchctl (with homebrew) the following commands will restart the server.

brew services restart postgresql

OR on older versions of **Brew**

launchctl unload homebrew.mxcl.postgresql.plist
launchctl load -w homebrew.mxcl.postgresql.plist


Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through