-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
EMQX is not able to connect to Postgres since version 5.0.14 #9907
Comments
same here with PostgreSQL version 15.1 |
@rubengees Sorry for keep you waiting. According to the log, this should not be caused by a server configuration error. You can see the It may be that your username and password are configured incorrectly, or you have enabled TLS for PostgreSQL, or you may not have opened the corresponding port. |
I have the same problem on 5.0.14. A downgrade to 5.0.13 made it possible to connect again with the same configuration as before. |
Also is there an |
Yes, I have the following error:
|
Hi @rubengees and @timesy ! I'm trying to reproduce the problem locally, but I could not make it
Using this config and correct credentials indeed yielded the same
So, could you share your |
Also, maybe check if the auth method in your |
Thanks for taking the time @thalesmg ! As my database is hosted on Azure I can't (to my knowledge) get the However I had a working installation, did the upgrade where it didn't work and then a downgrade shortly after where it was working again. I had this happen on two different instances with two different Postgres databases. I am using the emqx-operator, if this changes anything? |
@timesy thanks for the response, I'll have to investigate further, as I don't have access to an Azure instance. 🤔 Meanwhile, could you please check if the node IP from which EMQX is running in your k8s cluster can currently access the remote database (i.e.: the firewall port configurations are correct at the k8s and Azure sides)? One possible reason for error |
I am honestly not sure what the best way is to test it from inside the pod as no psql is installed and I have no root access in the container, any pointers? |
@thalesmg Thanks for answering! Same case for me, I use a managed DigitalOcean Postgres (14) database which I have no admin access to. My pods can access the database as can all other pods in the k8s cluster (from which some successfully do). Let me know If I can provide any useful information. |
If you have permissions to deploy pods to the same nodes in which EMQX is running, one option would be to run postgres pods on those same nodes and just try to connect using case gen_tcp:connect("my.db.host", 5432, []) of
{ok, P} ->
gen_tcp:close(P),
ok;
Error ->
Error
end. If this returns |
I believe I found the issue between the versions. It seems that, when one chooses to use SSL connections for Postgres in EMQX, the SSL configuration is slightly different in 5.0.16, which yields the different behavior. We will work on a fix for that. Meanwhile, would you like to try a patch in your server to verify you can connect? I've made a quick fix to test the hypothesis above and it worked locally for me, after reproducing your issue. To use the patch, just unzip the |
If still relevant: I ran the snippet you sent with my credentials via I tried the patch and it appears to be working! I mounted it into |
Same for me, thanks for the quick fix! |
…vior (5.0) Fixes emqx#9907 At v5.0.14, we changed the `ssl` option for the Postgres connector from `true` to `required`, but there was another transformation in `conn_opts/2` that led to an incorrect configuration. This change ended up preventing users from connecting to Postgres with their previous configurations after upgrading EMQX.
I've made another patched (worked locally for me in the same scenario as before) |
Just tested it on my k8s cluster and this patch works as well! |
Thank you @timesy and @rubengees for reporting and testing the patches. 🍻 This fix should be included in the next release ( |
What happened?
In version 5.0.13 EMQX was able to connect to Postgres with the following configuration (k8s):
As of version 5.0.14 this does not work anymore. Same for the latest version 5.0.16. The logs are:
What did you expect to happen?
EMQX connects to Postgres.
How can we reproduce it (as minimally and precisely as possible)?
No response
Anything else we need to know?
This may be related to #9614. I tried to configure the host in both these ways:
None worked or changed the logs.
EMQX version
OS version
Log files
See above.
The text was updated successfully, but these errors were encountered: