Question

Every 2-4 weeks I get (111: Connection refused) while connecting to upstream. Why?

I have a rails app that uses Nginx and Puma. Every 2-4 weeks my app starts giving 502 errors. When digging into log files, this is the error that comes up

[error] 8353#8353: *38966 connect() to unix:///home/deploy/apps/later_backend/shared/tmp/sockets/later_backend-puma.sock failed (111: Connection refused) while connecting to upstream, client: 69.162.124.234, server: later.bz, request: "GET / HTTP/1.1", upstream: "http://unix:///home/deploy/apps/later_backend/shared/tmp/sockets/later_backend-puma.sock:/", host: "later.bz", referrer: "http://later.bz"

A restart will fix the issue but I’m getting really sick of my app crashing every 2-4 weeks and having to do a manual restart. Amy thoughts on what this could be?


Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

What is your Droplet size? It could be that app gets killed due to it ran out of memory. Syslog could give you more information on that. Open it with your favorite text editor:

  1. sudo nano /var/log/syslog

Look at it, and if you see any Out Of Memory entry for your app, it was killed because it ran out of RAM.

In that case Droplet upgrade is recommend. You can add Swap space as alternative to upgrade. Because it is only after 2-4 weeks, you could have memory leaks somewhere. That means that app is not releasing used memory. This is something you have to find in source code if it’s available.

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

card icon
Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Sign up
card icon
Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We’d like to help.

Learn more
card icon
Become a contributor

You get paid; we donate to tech nonprofits.

Learn more
Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow – whether you’re running one virtual machine or ten thousand.

Learn more ->
DigitalOcean Cloud Control Panel
Get started for free

Enter your email to get $200 in credit for your first 60 days with DigitalOcean.

New accounts only. By submitting your email you agree to our Privacy Policy.

© 2023 DigitalOcean, LLC.