Run rails app on IP instead of port.

Posted March 3, 2017 4.7k views
Ruby on RailsUbuntu 16.04

Hello, I deployed my rails app on my droplet using this tutorial: -> with git hooks, puma and nginx.

But when my app is running I can only access it using http://my_ip_address:3000, when 3000 is app’s localhost port.

How to configure app in order to get it under http://my_ip_address?

Thank you in advance for your help.

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.

Submit an Answer
2 answers

Read the “Install and Configure Nginx” part of the tutorial you linked.

  • Already read and done. Her is my nginx config:

    upstream myapp {
    # Path to Puma SOCK file, as defined previously
    server unix:/home/me/myapp/shared/sockets/puma.sock fail_timeout=0;

    server {
    listen 80;

    root /home/me/todoardo/myapp;
    try_files $uri/index.html $uri @app;
    location @app {
        proxy_pass http://app;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_redirect off;
    error_page 500 502 503 504 /500.html;
    client_max_body_size 4G;
    keepalive_timeout 10;



You’ll need to change server_name in your server block as what you have now will most likely cause NGINX to fail when attempting to start/restart/reload.



Should be (as per the tutorial):

server_name localhost;

Other such valid configuration would be:



server_name *;




After changes have been made and saved, you’ll need to reload NGINX using:

systemctl reload nginx


service nginx reload