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
IEx 1.3.0 - Postgrex.Protocol failed to connect :econnreset #210
Comments
@nicbet I am afraid I don't think there is enough information to go on here. Would need to at least see the configuration and some tips how to reproduce. |
@fishcakez Configuration is what Phoenix 1.2.0 generates out-of-the-box via |
Please because I have no idea :) |
Application generated via File
File
File
|
Unless you can give us something more to go on there's not much we can do. You are the first one reporting this so my guess would be something with the local setup. Please let us know if you have any more information. |
I am also experiencing this (both locally and on CI). Running the Postgres v9.4 is running in Docker using the official image, with the standard port exposed to local. Elixir version: 1.3.1 File
|
@andykingking Like you I am executing my PSQL as a Docker container, official image (version 9.5.3). I'm wondering if some configuration in that docker image is messing with the connection pool? setting |
Just to clarify, the Postgres instance that I am connecting to is in a Docker container, however my Elixir app is running locally, which happens to have Postgres installed. |
@nicbet in other words, if you keep the pool size as 10 but increase max_connections on PSQL side to 1000, the problem disappears? |
Postgresql will return a postgresql protocol fatal error on too many connections. I am pretty sure this is an issue with your docker configuration but I am not sure what. |
@fishcakez Here is my
|
@andykingking sorry I dont know enough about docker to know. If the max connections is reached at the database level you should get log messages like this with postgresql 9.5:
|
@fishcakez Thus far I haven't seen the error you mentioned. I'll investigate further. |
Did you ever figure this out? I am having the same issue. I too am trying to dockerize my phoenix app and this is occurring on my compose up command. |
I'm getting something similar while going through the Phoenix book and doing the Rumbl application. I'm not trying to dockerize or anything. I'm on the chapter with tests and getting these errors which I'm not sure if this is related, but I can't figure it out.
Tests were humming along before... I don't know what I did, seems like something got corrupted. Even if I git checkout older commits that had all tests passing before and run I've pushed up what I have to a repo here: https://github.com/homanchou/phoenix_book_exercises I also tried git cloning what I pushed up and running
UPDATE: Completely rebooting my mac seems to have fixed the issue. Now all tests pass. |
@homanchou the error you mention is different. See |
Just to chime in, getting the same error as @homanchou, but I've observed an interesting chain of events, after leaving my Phoenix app alone for some time:
(And so on...) My environment is similar to @nicbet. This is a 'stock' Phoenix app (
(Edited to add...)
|
Are all of these on OSX? I haven't been able to reproduce this on linux. |
@fishcakez my environment is:
So very much the same as aisrael. |
I'm experiencing the same issue as @nicbet. I've installed postgres using homebrew and tried to increase the number of connections to 1000, but the result is the same: when I start the Phoenix server I occasionally get:
To give some context, I've recently updated a Phoenix 1.1.x app to 1.2.0 with Ecto 2.0.4. After the update everything was working fine, but then I reset the db by dropping, creating, and migrating and I started getting this kind of errors. Sorry if this not enough to reproduce, I'm hoping this can give more info around this issue and I'm curious to know if others have received the same error from their phoenix apps. |
I got this error to when I went from a The prod.exs file has a pool_size of 20, which is also the limit of Postgres connections on the hobby:dev size plan. When I'd do anything else that run the single web dyno (like I just dropped my pool_size from 20 to 10, and the errors are gone. I do not know why this never happened when I was running Ecto 1, Phoenix 1.1, Elixir 1.2 on the same heroku dyno size before the migration. |
@joshcrews In Ecto 1.0 connections were setup lazily so if your app didnt need 20 connections only a subset would connect. However in Ecto 2.0 connections are setup eagerly, which should provide better behaviour when errors occur. If you are getting The following PR phoenixframework/phoenix_guides#513 and associated issue should provide you with some useful information given you are using phoenix and heroku. |
I have this same problem |
@nenoalmeida could you let us know the postgrex, postgresql, OS and elixir versions? |
I am having the same problem. Here is a repo I just uploaded with all of my current code (its basically just the templates that phoenix produces). My entire console output is in the readme. I also added the There is nothing sensitive in my code yet. I will most likely rebuild from scratch after I find out what the problem is. OS is OSX El Cap 10.11.5 and I'm using Docker for Mac |
Guys, having the same issue. It worked fine for several days, then at some point code raised an exception and after we applied a fix and recompile it, it throws this error. We didn't update any packages. mix.lock
Exception:
Using psql and data in prod.secret.exs I'm able to connect to the database, which is located on separate server. |
@nateless just to be clear you are getting this exact error:
And it is occurring on OSX using docker? |
@fishcakez,
And no, we do not use docker, its Ubuntu 16.04.1 LTS on a dedicated server. PS: Well after reviewing the error, we actually have a different one. Sorry for the confusion. Got a bit tired :( |
@nateless do any connections succeed in connecting? |
@fishcakez, nope. however as I've mentioned before we can connect to the database using PS: exactly the same code ( but with different postgres settings in dev env ) works on my mac with local postgres. |
@nateless can you access iex on the node and try something like this: pid(0, 262, 0) |> :sys.get_state(10_000) |> get_in([:mod_state, :opts]) And verify those are the options you expect. Will need to use the relevant numbers for the pid, which would be 0 262 and 0 based on the first log entry in this post #210 (comment). The second would be 0, 264 and 0. |
@fishcakez, after restarting postgres server, this error is gone. Idk what it was but if you need my help just ping me. |
@nateless if you can reproduce and tell use what is going wrong that would be great 😉. I am unable to reproduce this. |
Having the exact same problem as @samueleaton, also trying to dockerize my app. My setup seems to be working fine, i can connect to the postgres database fine from my elixir container, using psql. But the elixir app is just spamming, with the exact same connection information as i feed psql..
|
@MartinElvar is OTP 19 adds experimental support for unix sockets so we likely wont add the feature until OTP 20 is released and an Elixir release is out that requires OTP 19+. |
@fishcakez My apologies, this doesn't seem to be a problem with postgrex, or for that matter Phoenix. If i run..
I actually get a :ok, which means the problem may be else where, maybe in the Postgres Ecto adapter. Sorry for the noise. :) |
@MartinElvar FWIW |
@fishcakez So this means that it works then?
|
Just for the record, here's my Ecto config.
|
As i turns out, i copy pasted the configuration from the Ecto readme, and therefor had host over hostname, i made a PR elixir-ecto/ecto#1743. It works now 😄 . |
Thanks @MartinElvar. Just to clarify for future people, this issue is specifically about the exact log error: "connection reset by peer - :econnreset". If not this error please open a new issue. |
Closing this because there's currently nothing actionable for us and there haven't been any activity for two months. Please post here if you have anything to add. |
I see that this is closed, but has anyone found a good solution for this? |
In case this will help anyone, I was seeing this error vomited to standard output on loop:
when trying to Putting this here to help anyone else who wants a quick fix for the same problem. I'm new to phoenix and have next to no idea what I'm doing. |
I've had similar issues trying to connect to a local postgres instance (tcp recv: timeout) on Mac OSX. The problem for me was the following. My local postgres instance could not bind properly to the IPV4 socket (but it could bind to IPV6 socket). I was using brew to start the service and this error went quietly, I only could notice it when I manually tried to start the service. This was the reason Phoenix/Ecto could not access the instance, but other means I had tried could (python and psql). What was keeping postgres from binding to IPV4 socket was a process called prl_naptd which is a process from my VM software (Parallels Desktop). So by killing this process and restarting postgres service, it was able to successfully bind to both IPV4 and IPV6 sockets and then Phoenix/Ecto was able to connect. I hope this helps other with similar problems. |
I always wind up here when I forget about this error.. so for myself and anyone else having issues on Heroku, the guide that @pachun mentioned offers the following solution:
My understanding is that the *The solution mentioned above assumes you set the |
Phoenix documentation has been updated to hexdocs.pm, you can find the link mentioned above here. |
Once in a while, execution of
iex -S mix
will result in one or more error lines stating:Relevant dependency versions are listed as:
The text was updated successfully, but these errors were encountered: