I'm developing a Rails application with a postgresql database.
MacOS 10.15.3
ruby 2.6.3p62
postgres 12.3
I took a break and when I came back my laptop was slow to wake up. After pressing the on/off fingerprint button a few times, it eventually went into the startup sequence. This was odd because I did not recall shutting it off.
After starting, everything seemed normal. I opened some applications and resumed my work. But, when I tried to run a database migration, I got errors about not being able to connect to the server.
$ bundle exec rake db:migrate
warning: parser/current is loading parser/ruby26, which recognizes
warning: 2.6.5-compliant syntax, but you are running 2.6.3.
warning: please see https://github.com/whitequark/parser#compatibility-with-ruby-mri.
rake aborted!
PG::ConnectionBad: could not connect to server: Connection refused
Is the server running on host "localhost" (127.0.0.1) and accepting
TCP/IP connections on port 5432?
could not connect to server: Connection refused
Is the server running on host "localhost" (::1) and accepting
TCP/IP connections on port 5432?
/Users/emerson/.rbenv/versions/2.6.3/bin/bundle:23:in `load'
/Users/emerson/.rbenv/versions/2.6.3/bin/bundle:23:in `<main>'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)
I tried to start it with homebrew but no luck. I eventually read another question that suggested installing the Postgres app and using this to force it to restart. At first the app said "Empty data directory". I clicked "Initialize" and it worked. And I no longer get the bad connection error. But ALL my previous postgres databases are gone.
I'm puzzled. How could this have happened? And with almost no interaction from me whatsoever! Did Postgres.app wipe all my previous data with one click?
Related
While installing PostgreSQL on Windows 11 I get the error:
the database cluster initialization failed
then SQL Shell gives me an error
psql: error: could not connect to server: Connection refused
(0x0000274D/10061)
Is the server running on host "localhost" (::1) and accepting
TCP/IP connections on port 5432? could not connect to server: Connection refused (0x0000274D/10061)
Is the server running on host "localhost" (127.0.0.1) and accepting
TCP/IP connections on port 5432? Press any key to continue . . .
There's even no Postgres in Services and the data folder is empty. So I uninstalled it and got this error while doing so:
error stopping service PostgreSQL-x64-13
After this, I've tried many different ways of reinstalling Postgres, including running it as Admin, creating a separate user named postgres with Admin rights, etc. In fact, this comprehensive article offers a lot of different ways to deal with this issue: https://forums.holdemmanager.com/general-support/150771-solved-postgresql-database-cluster-initialisation-failed.html
However, none of them worked for me. It seems that I exhausted all possible solutions. Any ideas on what I can try now?
I am new to Ubuntu operating system and trying to install postgresSQL in my system.
After completing the installation and entering postgres mode when I enter the command pgsql, it gives me this error
psql: 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"?
what could possibly be wrong??
Probably the postgresql server is not running; you can run netstat -adp to see if postgres is listening on port 5432.
If it isn't, then it most likely isn't running; systemctl status postgresql will help identify if it is even installed, and if it has run into any issues (for further details, see https://mydbanotebook.org/post/troubleshooting-01/)
If it is running and seems healthy, then it might not be configured to accept connections in whichever way you are connecting (which user, database, host/network etc) - see details about the pg_hba.conf file that includes rules for this - https://www.postgresql.org/docs/9.1/auth-pg-hba-conf.html
After install, you must create an instance with initdb.
Later, change the listen_address to *, restart the service and now you can check the port.
Check the pg log for the message: "postgres is ready to accept connections"
I'm using the latest macOS Catalina.
I've looked into other threads but not sure how to solve mine because I have two errors on both Postgres and Postico.
Postgres says I have a Stale postmaster.pid file
Postico says
could not connect to server: Connection refused
Is the server running on host "localhost" (::1) and accepting
TCP/IP connections on port 5432?
could not connect to server: Connection refused
Is the server running on host "localhost" (127.0.0.1) and accepting
TCP/IP connections on port 5432?
I went on Youtube for a solution to address the stale postmaster.pid file, and deleted it using the terminal... but the error still persists..
Should I uninstall, and reinstall Postgres and Postico?
Using the terminal to delete postmaster.pid didn't do it for some reason. I had to do it via Finder manually.
Problem solved :)
I had the same error on Postico.
I just reinstalled Postgres.app and initialize again my data base on the app, and after go back on Postico.
I am trying to view databases with pgAdmin. After starting pgAdmin and successfully entering my "master password". I get the following error while trying to open up the only instance, in this case: "PostgeSQL 12".
I am getting this pgAdmin error:
could not connect to server: Connection refused Is the server running on host "localhost" (::1) and accepting TCP/IP connections on port 5432? could not connect to server: Connection refused Is the server running on host "localhost" (127.0.0.1) and accepting TCP/IP connections on port 5432?
Picture of: Connection refused error
After entering the correct and only password I have used for 4 or so different programs: I get the same pop-up error. None of the programs access the database any longer.
I did try right-clicking "PostgreSQL 12" and clearing the password but that did not resolve the issue.
I will say that I recently restored from a backup because I did a hardware upgrade where I swapped out a HDD to a SSD.
I am running the following:
MacOS High Sierra 10.13.6
PostgreSQL 12
pgAdmin 4
UDATE 1:
I found something: I think this is the installation full path: /Library/PostgreSQL/12/bin
I ran from bin:
./pg_ctl --help
and got the full help menu options. Would I now have to run status, start, or stop on the correct server? Which server or file might that be? Is it data, which seems to be locked?
UPDATE 2:
I ran ./pg_ctl start
and got: "pg_ctl: no database directory specified and environment variable PGDATA unset"
UPDATE 3:
I ran ./pg_ctl start -D /Library/PostgreSQL/12/data
and got: "pg_ctl: could not open PID file "/Library/PostgreSQL/12/data/postmaster.pid": Permission denied"
Picture of: Directory
UPDATE 4:
ran from the bin folder found at /Library/PostgreSQL/12/bin I ran:
sudo -u postgres ./pg_ctl start -D /Library/PostgreSQL/12/data
and after inputing password:
waiting for server to start....2020-04-22 15:57:51.766 CDT [5255] LOG: starting PostgreSQL 12.2 on x86_64-apple-darwin, compiled by Apple LLVM version 6.0 (clang-600.0.54) (based on LLVM 3.5svn), 64-bit
2020-04-22 15:57:51.766 CDT [5255] LOG: listening on IPv6 address "::", port 5432
2020-04-22 15:57:51.766 CDT [5255] LOG: listening on IPv4 address "0.0.0.0", port 5432
2020-04-22 15:57:51.768 CDT [5255] LOG: listening on Unix socket "/tmp/.s.PGSQL.5432"
2020-04-22 15:57:51.782 CDT [5255] LOG: redirecting log output to logging collector process
2020-04-22 15:57:51.782 CDT [5255] HINT: Future log output will appear in directory "log".
stopped waiting
pg_ctl: could not start server
So, to answer some questions, I could not start the server; hence, the error I am getting in pgAdmin.
If you are on windows, You need to start the Postgres in the task manager services section. That way It would connect automatically and ensure there is no firewall connection block on your port 5432. I tried it, and it worked.
I am using pgAdmin4 and developing a node.js app.I had an abrupt shutdown of the computer and I can no longer connect to the postgresql server.
The error I get when trying to connect is :
psql: could not connect to server: Connection refused (0x0000274D/10061)
Is the server running on host "localhost" (::1) and
accepting TCP/IP connections on port 5432?
could not connect to server: Connection refused (0x0000274D/10061)
Is the server running on host "localhost" (127.0.0.1) and
accepting TCP/IP connections on port 5432?
I tried to run postgres -D /usr/local/var/postgres/ as suggested in this SO answer. However it gave me the following error :
postgres: could not access directory "usr/loval/var/postgres": No such file or directory
Run initdb or pg_basebackup to initialize a PostgreSQL data directory.
So I just manually deleted the postmaster.pid file inside the PostgreSQL/.../data folder. But I still cannot connect to the database server.
I have checked the postgresql.conf file, and
the listen addresses is already set as listen_addresses = '*', and the port is set to 5432.
I also tried deleting the pgAdmin file in the AppData/Roaming folder.But it gave me an error:
The application server could not be contacted
and then afterwards the same problem of not being able to connect to the server happens.
Funny enough, it was a matter of just deleting the pdAdmin file in AppData/Roaming folder, and then restarting the computer and restarting the pgAdmin4. That solved it for me.
Meet the same challenge while settings up PostgreSQL to work with a Python/Django project.And i resolved the issue here, after reading the official PostgreSQL-9.6.16 documentation.