Report this

What is the reason for this report?

Unable to connect on deploying a rails app with Nginx, Capistrano and Puma on Ubuntu 16.04

Posted on March 20, 2017

Hello:

I am trying to deploy my rails app on Ubuntu 16.04 adapting this tutorial.

I have gone through all the steps and when I visit the IP address I get “unable to connect, Firefox can’t establish a connection to the server at IP address”

I have checked my logs and none of them show any sign of errors: nginx.access.log

41.82.2.246 - - [20/Mar/2017:13:26:04 +0000] "GET / HTTP/1.1" 301 5 "-" "Mozilla/5.0 (Macintosh; Intel M$
51.36.233.18 - - [20/Mar/2017:13:29:22 +0000] "\xC1\x99[\xB21\xA9\x92" 400 182 "-" "-"
51.36.233.18 - - [20/Mar/2017:13:29:23 +0000] "\xDEzx\xFC\x0C\xC6\x8D\xD3\xD9\x1A\xE1\x1F\xC4\xD0\xF0/\x$
51.36.233.18 - - [20/Mar/2017:13:29:23 +0000] "\xA5\xA8\xBCq\x16\xA6\xEC\xC2\xF7\x0Fz\xEAn\x83\xD92xu\xB$

nginx.error.log

[info] 3003#3003: *3 client sent invalid method while reading client request line, c$
[info] 3003#3003: *4 client sent invalid method while reading client request line, c$
[info] 3003#3003: *5 client sent invalid method while reading client request line, c$
[info] 3003#3003: *6 client closed connection while waiting for request, client: 41.$

puma.error.log

* Listening on unix:///home/deploy/apps/appname/shared/tmp/sockets/appname-puma.sock

puma.access.log

=== puma startup: 2017-03-20 13:24:07 +0000 ===

production.log - shows migrations, last lines are

I, [2017-03-20T13:24:03.303477 #2436]  INFO -- : Migrating to AddGuidToPrescriptions (20170310185442)
D, [2017-03-20T13:24:03.304288 #2436] DEBUG -- :   ^[[1m^[[35m (0.1ms)^[[0m  ^[[1m^[[35mBEGIN^[[0m
D, [2017-03-20T13:24:03.305111 #2436] DEBUG -- :   ^[[1m^[[35m (0.3ms)^[[0m  ^[[1m^[[35mALTER TABLE "pre$
D, [2017-03-20T13:24:03.306443 #2436] DEBUG -- :   ^[[1m^[[35mSQL (0.3ms)^[[0m  ^[[1m^[[32mINSERT INTO "$
D, [2017-03-20T13:24:03.307318 #2436] DEBUG -- :   ^[[1m^[[35m (0.6ms)^[[0m  ^[[1m^[[35mCOMMIT^[[0m
D, [2017-03-20T13:24:03.310861 #2436] DEBUG -- :   ^[[1m^[[36mActiveRecord::InternalMetadata Load (0.3ms$
D, [2017-03-20T13:24:03.317530 #2436] DEBUG -- :   ^[[1m^[[35m (0.2ms)^[[0m  ^[[1m^[[35mBEGIN^[[0m
D, [2017-03-20T13:24:03.319872 #2436] DEBUG -- :   ^[[1m^[[35mSQL (0.7ms)^[[0m  ^[[1m^[[32mINSERT INTO "$
D, [2017-03-20T13:24:03.322738 #2436] DEBUG -- :   ^[[1m^[[35m (2.5ms)^[[0m  ^[[1m^[[35mCOMMIT^[[0m
D, [2017-03-20T13:24:03.323393 #2436] DEBUG -- :   ^[[1m^[[35m (0.4ms)^[[0m  ^[[1m^[[34mSELECT pg_adviso$

All input and help welcome thanks!



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!

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.

Hello,

For anyone stumbling on the question,

Based on the information provided, it’s possible that the app is not running properly or is not listening on the correct port or the port is not allowed. Here are a few steps you can take to troubleshoot the issue:

  1. Check if your app is listening on the correct port

Your app should be listening on a specific port, which you can check by running the following command:

sudo netstat -plunt | grep LISTEN

Look for a line that contains the port your app is supposed to be running on (usually port 80 or 3000). If you don’t see it, then your app is not listening on the correct port.

  1. Check if your firewall is blocking traffic

Make sure that your firewall is not blocking incoming traffic to the port your app is running on. You can check this by running the following command:

sudo ufw status

If your firewall is enabled, make sure to allow incoming traffic to the correct port using the following command:

sudo ufw allow <port>/tcp

Replace <port> with the port your app is running on (usually port 80 or 3000).

  1. Check your Nginx configuration

Make sure your Nginx configuration is correct by running the following command:

sudo nginx -t

This will check if your Nginx configuration has any syntax errors. If it does, fix them and restart Nginx using the following command:

sudo service nginx restart

If you have followed all these steps and are still unable to connect to your app, please provide more information about your setup and any error messages you see in your logs.

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.