The Rails application is running on port 3000:

$ bundle exec rails server -b
=> Booting Unicorn
=> Rails 3.2.21 application starting in development on
=> Call with -d to detach
=> Ctrl-C to shutdown server
(eval):1: warning: encountered \r in middle of line, treated as a mere space
listening on addr= fd=14
worker=0 spawning...
master process ready
worker=0 spawned pid=5811
worker=0 ready

Website is available on the Virtual Machine:

$ wget
--2016-05-05 05:15:54--
Connecting to connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/html]
Saving to: `index.html'

        [ <=>                                   ] 42,036        --.-K/s   in 0s      

2016-05-05 05:15:55 (222 MB/s) - `index.html' saved [42036]

But from the host machine:

$ wget
--2016-05-05 00:07:02--
Connecting to failed: Connection refused.

Port Scanning host:

 Open TCP Port:     21          ftp
 Open TCP Port:     22          ssh
 Open TCP Port:     80          http
 Open TCP Port:     88          kerberos
 Open TCP Port:     111         sunrpc
 Open TCP Port:     445         microsoft-ds
 Open TCP Port:     548         afpovertcp
 Open TCP Port:     631         ipp
 Open TCP Port:     965
 Open TCP Port:     975
 Open TCP Port:     1015
 Open TCP Port:     1019
 Open TCP Port:     2049        nfsd
 Open TCP Port:     2200        ici
 Open TCP Port:     2222        rockwell-csp2
 Open TCP Port:     3300
 Open TCP Port:     5432        postgresql
 Open TCP Port:     8080        http-alt

This is the basic contents of /private/etc/hosts:   localhost   test.localhost broadcasthost
::1             localhost 
fe80::1%lo0 localhost  vagrant  # VAGRANT: c460068dd8a5a09607cfd3402843d82a (local) / 0668df93-b211-421f-86db-bb2ff8e57175  vdd.dev  # VAGRANT: 07e9613958e0db441d6b9af1328fa214 (default) / 4d655cd6-bf5a-442a-8093-4ac431b7d890

The nginx/error.log is just confirming the refused connection and Unicorn log equally uninformative as far as I can tell.

This is contents of /etc/nginx/sites-available/my_application:

upstream unicorn {
  server unix:/home/vagrant/apps/ofn_america/shared/sock/unicorn.ofn_america.sock fail_timeout=1;

server {
  listen 80;
  rewrite ^/(.*)$1 permanent;

server {
  listen 80;
  root /home/vagrant/apps/ofn_america/current/public;

  try_files $uri/index.html $uri @unicorn;
  location @unicorn {
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_redirect off;
    proxy_pass http://unicorn;

  location ~ ^/(assets)/ {
    gzip_static on;
    expires max;
    add_header Cache-Control public;
    #add_header Last-Modified "";
    #add_header ETag "";
  error_page 500 502 503 504 /500.html;
  client_max_body_size 4G;
  keepalive_timeout 60;

Any suggestions?

I'm not sure where else to poke around.

  • 1
    The answer will depend on the Networking Adapter type you are using (ie. Bridged, NAT, Host-Only, etc). Basically, your app is running in a VM, always refers to the local machine, so in the VM its referring to the VM, but on the host, its referring to the host machine.
    – heavyd
    May 5, 2016 at 5:58

1 Answer 1


Sounds like you need to forward traffic from the host to the guest. I'm not familiar with Vagrant specifically, but this looks like how you'd do it:


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .