My app has fallen over as it can't connect to the postgres DB and when I try to connect to the DB via ssh and psql I get the following message:
psql: could not connect to server: Connection refused
Is the server running on host "<GEAR_ID>-<NAMESPACE>.rhcloud.com" (<IP_ADDRESS>) and accepting
TCP/IP connections on port <PORT_NUMBER>?
Running rhc app show --state prints:
Cartridge jbossas-7, haproxy-1.4 is started
Cartridge postgresql-9.2 is started
also, running rhc app show shows nothing unusual.
I can't telnet to the above IP_ADDRESS & POST_NUMBER, which kinda looks like communication has been broken between the 2 gears.
Any ideas?
I had the same problem. Using pg_ctl instead of the rhc commands fixed it for me.
$ rhc ssh <appname>
[...rhcloud.com ...]\> pg_ctl restart
pg_ctl: old server process (PID: 20034) seems to be gone
starting server anyway
server starting
To restart your entire application:
rhc app restart <app_name>
TO restart just your postgresql cartridge:
rhc cartridge restart <cart_type> --app <app_name>
You can get the cart type by running
rhc app show <app_name> --gears
And looking for the cartridge name under the "cartridges" heading
Ok, so I managed to work around this issue but man it was a PITA.
Since I couldn't find any useful help on the web around this problem, I've ended up creating a new app based on my old one, and using pg_dump and psql to save and restore the db from the old application into my new app.
I'm still none-the-wiser as to why the original app was no longer able to communicate from the main jboss gear to the postgresql gear, even though the postgres server was up and running.
Perhaps (hopefully) someone from openshift will want to look into this. If so I'll keep my old broken app around for a while.
Related
I'm having trouble initializing a database with sequelize in my docker image. I keep getting a connection refused error because of the unix socket since I can't use localhost.
I've read how to create one with a script, but my project uses sequelize.
I've also tried various tactics with socket connections and using socat
psql commands will succeed in my init script, but the yarn command or sequelize commands end up with
ERROR: connect ECONNREFUSED 127.0.0.1:5432
My finial init script looks like this:
socat TCP-LISTEN:5432 UNIX-CONNECT:/var/run/postgresql/.s.PGSQL.5432 &
yarn --cwd /root db-create
The create command just calls dotenv sequelize db:create
I'm not really sure where to go from here. It seems like this should be a simple thing. Am I just missing something obvious?
-EDIT
It's worth pointing out that this was working fine with a postgres install. It was working fine when we just fired up postgres in the database and run the yarn commands after. The only difference here is we are trying to have the database created and migrated when the container starts so it's not a manual process.
If you bind to localhost you should be able to hit it at 127.0.0.1:5432
socat TCP-LISTEN:5432,bind=127.0.0.1,reuseaddr,fork UNIX-CLIENT:/var/run/postgresql/.s.PGSQL.5432 &
I've just installed Postgressql (9.5.4 vc14_0) and Psycopg2 (2.7.5 py36h74b6da3_0) and I'm trying to use them within my Anaconda environment on Windows 10.
Whenever I run psycopg2.connect("host=localhost user=postgres") in a python interpreter or just psql on the command line I get this error:
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've looked at other Stackoverflow questions regarding this, some answers say to look into a pg_hba.conf file although I haven't be able to find any. Where can I find a pg_hba.conf file for my Postgresql in my Anaconda Environment for Windows? If I have to make one, what should go in it? I haven't seen another SO question that uses the same Postgresql-Anaconda-Windows setup that I'm using.
Also I've looked into services.msc but haven't seen a service regarding postgresql.
I just ran into this error as well. Similar to what you did, I followed the installation page, ran conda install -c anaconda postgresql and received the same error in your post.
I have used postgresql through direct installation before, in osx and as far as I can recall, you could just psql into the database once the installation is complete.
Maybe this isn't the case for anaconda installations. I overcame this by initializing a new database system in a new, empty folder. In my case, I created a new folder in "\AppData\Local\conda\"
-- Initialize the database system
pg_ctl init -D <path_to_your_database_system>
-- Start the database
C:/Users/kerwei/AppData/Local/Continuum/anaconda3/envs/py36/Library/bin/pg_ctl -D <path_to_your_database_system> -l logfile start
NOTE: After playing around with for awhile, I realized that once you exit the conda environment, the database instance gets terminated too - without properly shutting down. As I don't use it for production stuffs, it doesn't really bother me. However, further steps can be taken to include the database booting and shutting down during conda activate or conda deactivate to make it less cumbersome.
I am attempting to start a Postgres SQL server on amazon Linux using the command
sudo service postgresql start
I installed the server using this method. I have added it here for simplicity
sudo rpm -i https://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-6-x86_64/pgdg-ami201503-96-9.6-2.noarch.rpm
and then
sudo yum install postgresql96-server.x86_64
after which i did this to install the command line tools for postgres
sudo yum install postgresql96.x86_64 postgresql96-libs.x86_64
Any suggestions on how I can start the server ? I usually start the server using
the command
sudo service postgresql start
however its not working in this case as it says "Unrecognized service"
I then tried this
postgres -D /usr/local/pgsql/data
postgres: could not access directory "/usr/local/pgsql/data": No such file or directory. Run initdb or pg_basebackup to initialize a PostgreSQL data directory.
Having the same issue, or similar. May be I installed pgsql from source, don't remember. We could make our own service start files. How? Let's find out! >>RTFM<< starting with what we already know:
man service
which leads us to chkconfig(8), so
man chkconfig
and it gives us an option
chkconfig --add ${svcname}
to add a brand new service under a name we choose!
But before we do, we might actually want to check what's already there. With
service --status-all
we get a list of all known services and their run status. And I found "postmaster" in my list, and as you might know, the PostgreSQL master server to connect to used to be called "postmaster". Yet, when I try
service postmaster status
it also tells me it doesn't know such service. OK, forget it -- for now -- just let's move on with making our own! But I still want to peek what there is in run-level 3 (normal server run level). So I go
ls -1 /etc/rc.d/rc3.d |fgrep post
and there I find: "K36postgresql95"! So, accordingly our service name should be "postgresql95". Trying that:
service postgresql95 status
it says now "postmaster is stopped". Confusingly the name the service reports for itself both in service --status-all and when we individually inquire for it is different than the name used to actually address it in the service command. Good to know. Easy enough to search /etc/rc.d for the name of interest.
service postgresql95 start
now starts the service. And check with
psql -U ${pguser} ${pgdb}
and I find that working. So now all I need to do is enable that service at system boot to auto-start
chkconfig --levels 3 postgresql95 on
and that works, doesn't it?
PS: It doesn't matter that I happen to run version 9.5
I recently installed PostgreSQL 9.2.24 on Amazon Linux 2 and I had to initialize the database manually before being able to create ROLE and DATABASE as I normally would on Ubuntu.
// initialize database after installing with yum
$ sudo postgresql-setup initdb
// start
$ sudo systemctl start postgresql.service
As of today, suddenly, my Postgres 9.6 Windows 10 service fails to start up the server. Here is what I used to register the service:
pg_ctl register -N PostgreSQL-9.6.10 --pgdata=%DATA_HOME%\Postgres ^
--log=%DATA_HOME%\Postgres\server.log
When I go to my Windows service control panel, when I hit start for this new service, which is registered okay, it reports that the service is started for a brief moment and then it switches the status to stopped. I am unable to find any logging of the service itself, to get a trace of why this might be happening.
The service does start fine when I do it manually:
pg_ctl -D %DATA_HOME%\Postgres -l %DATA_HOME%\Postgres\postgres.log start
Any idea what the problem might be and how to recover my service?
After install pgAdmin III from Ubuntu Software Center, I opened it and it required to add a connection to a server. So I filled in information as below:
Upon clicking on Ok Button, it showed the error message
Error connecting to the server: could not translate host name
"http://127.0.0.1" to address: Name or service not known
As message indicated, I thought the postgres service was not started. Therefore, I went on go terminal console and start service by entering sudo service postgresql start, but it returned Failed to start postgresql.service: Unit postgresql.service failed to load: No such file or directory.
. What's wrong or missing for my pgAdmin III? I'm just using Ubuntu earlier and I have never this problem on windows. Thanks.
http://127.0.0.1 is more a URL, that field is looking for a host so simply remove the http:// to leave the localhost's IP address 127.0.0.1 or type localhost if that resolves to the correct address (it should, usually, via /etc/hosts or the like)
Also, Debian/Ubuntu tend to ship the database servers separately. For Ubuntu, the postgresql package (which requires postgresql-common) package should include /lib/systemd/system/postgresql.service therefore you should be able to sudo systemctl start postgresql
Do you have postgresql (as opposed to postgresql-client) installed?