Rails Bad Gateway Error
Contents |
here for a quick overview of the site Help Center rails nginx unicorn 502 bad gateway Detailed answers to any questions you might have Meta 502 bad gateway nginx rails Discuss the workings and policies of this site About Us Learn more about Stack 502 bad gateway nginx passenger rails Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question
Connection Refused While Connecting To Upstream
x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Nginx, Unicorn and Rails = 502 Bad Gateway up vote 2 down vote favorite Im trying to unicorn rails setup Nginx, Unicorn and Rails application to work together. Nginx and Nnicorn are running, I checked that using ps command. But when trying to access my page Ive got 502 Bad Gateway Nginx error log has line: 2015/03/18 19:53:26 [error] 14319#0: *1 connect() to unix:/var/sockets/unicorn.mypage.sock failed (11: Resource temporarily unavailable) while connecting to upstream What can be the problem? my /etc/nginx/conf.d/default.conf upstream app { server unix:/var/sockets/unicorn.mypage.sock fail_timeout=0; } server { listen 80; server_name mypage.com; # Application root, as defined previously root /home/rails/mypage/public; location ^~ /assets/ { gzip_static on; expires max; add_header Cache-Control public; } try_files $uri/index.html $uri @app; location @app { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_redirect off; proxy_pass http://app; } error_page 500 502 503 504 /500.html; client_max_body_size 4G; keepalive_timeout 10; } /home/rails/mypage/config/unicorn.rb working_directory "/home/rails/mypage" pid "/home/rails/mypage/pids/unicorn.pid" stderr_path "/home/rails/mypage/log/unicorn.log" stdout_path "/home/rails/mypage/log/unicorn.log" listen "/var/sockets/unicorn.mypage.sock", backlog: 1024 worker_processes 2 timeout 30 ruby-on-
here for a quick overview of the site Help Center Detailed answers to any nginx error log questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow http://stackoverflow.com/questions/29133374/nginx-unicorn-and-rails-502-bad-gateway is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Nginx configuration 502 bad gateway error up vote 0 down vote favorite I have a configured nginx sites enabled/available that when I run: nginx -t I get a successful test http://stackoverflow.com/questions/23417097/nginx-configuration-502-bad-gateway-error and when I: service nginx restart thin restart -s 1 My 502 error goes away but only for ten seconds and then it shows up again. my sites-available is: upstream myapp { server 0.0.0.0:3000; } server { listen 80 default; access_log /webservices/crawler/log/access.log; error_log /webservices/crawler/error.log; root /webservices/crawler/public/; index index.html; client_max_body_size 500M; location / { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_redirect off; if (-f $request_filename/index.html) { rewrite (.*) $1/index.html; break; } if (-f $request_filename.html) { rewrite (.*) $1.html; break; } if (!-f $request_filename) { proxy_pass http://myapp; break; } } } Does anyone know why my config only works for a few seconds? Thank you for any help and just let me know if you need to see any of my other code. thin restart -s 2 output: /# thin restart -s 2 Stopping server on 0.0.0.0:3000 ... /usr/local/lib/ruby/gems/2.0.0/gems/thin-1.5.1/lib/thin/daemonizing.rb:131:in `send_signal': Can't stop process, no PID found in tmp/pids/thin.3000.pid (Thin::PidFileNotFound) from /usr/local/lib/ruby/gems/2.0.0/gems/thin-1.5.1/lib/thin/daemonizing.rb:113:in `kill'
Sign in Pricing Blog Support Search GitHub https://github.com/dokku/dokku/issues/1429 This repository Watch 363 Star 12,504 Fork 1,097 dokku/dokku Code Issues 32 Pull requests 12 Projects 0 Wiki Pulse Graphs https://community.webfaction.com/questions/13999/troubleshoot-502-with-rails New issue nginx 502 Bad Gateway error with second Rails app #1429 Closed jacobpatton opened this Issue Aug 28, 2015 · bad gateway 6 comments Labels None yet Milestone No milestone Assignees No one assigned 2 participants jacobpatton commented Aug 28, 2015 I'm trying to run a second rails app at a subdomain, and I'm running into problems getting it to run. 502 bad gateway (Both apps are running on a single DigitalOcean droplet with dokku, nginx, and Rails.) The nginx error log I'm seeing is: 2015/08/28 02:19:06 [error] 24944#0: *3071 connect() failed (111: Connection refused) while connecting to upstream, client: 61.135.190.201, server: crm.topzip.co, request: "GET / HTTP/1.0", upstream: "http://172.17.0.76:5000/", host: "192.241.218.17", referrer: "http://www.baidu.com/s?wd=www" Here's the nginx.conf file: server { listen [::]:80; listen 80; server_name crm.topzip.co ; access_log /var/log/nginx/crm.topzip.co-access.log; error_log /var/log/nginx/crm.topzip.co-error.log; location / { gzip on; gzip_min_length 1100; gzip_buffers 4 32k; gzip_types text/css text/javascript text/xml text/plain text/x-component application/javascript application/x-javascript application/json application/xml application/rss+xml font/truetype application/x-font-ttf font/opentype application/vnd.ms-fontobject image/svg+xml; gzip_vary on; gzip_comp_level 6; proxy_pass http://crm.topzip.co; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection upgrade; proxy_set_header Host $http_host; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Forwarded-For $remote_addr; proxy_set_header X-Forwarded-Port $server_port; proxy_set_header X-Request-Start $msec; } include /home/do
a Rails app. What could I check? rails asked 12 Jul '13, 06:28 Federico Tom... 3●5 accept rate: 0% One Answer: active answersoldest answersnewest answerspopular answers 0 A "502 - Bad Gateway" error means that our frontend nginx webserver was unable to connect to the port your rails app is listening to and proxy requests. You should start by making sure that your application is running. You can see that if you log into the server via ssh and use the ps command. Try for example ps -u $USER -o pid,etime,command. This will list all the id of your processes, the time that has passes since they started and the command itself. If you do not see your rails application there, try restarting it by using the start command in its bin directory. permanent link answered 12 Jul '13, 09:55 iliasr ♦♦ 1.4k●4 accept rate: 35% I see the application running but still I get the same error (12 Jul '13, 09:58) Federico Tom... If your application is running, you should make sure that it is listening for requests from our nginx to the correct port. You can use the fuser NNNN/tcp command, where NNNN is the number your app is listening according to our control panel. The fuser command's output should map the process id of your app, which you've located using the ps command earlier. If you are still having issues, feel free to open a support ticket for us to check it. (12 Jul '13, 10:08) iliasr ♦♦ Hi, I'm having the same problem. I followed the steps above and fuser tells me that my application is listening to PIDs belonging to an nginx master process and an nginx worker process. Should it be listening to Passenger RackApp? Is that the problem? (20 Feb '15, 00:23) Pablo Urenda Pablo, you should check the application logs for hints on why it is not starting, or crashing. If ngnix is running than checking the nginx logs is the next step. Fuser will report nginx, since that is what serves passenger. (20 Feb '15, 02:17) johns ♦♦ Your answer toggle preview community wiki: Follow this questionBy Email:Once you sign in you will be able to subscribe for any updates hereBy RSS: Answers Answers and Comments Markdown Basics *italic* or _italic_ **bold** or __bold__ link:[text](http://url.com/ "title") image?![alt text](/path/img.jpg "title") numbered list: 1. Foo 2. Bar to add a line break simply add two spaces to where you would like the new line to be. basic HTML tags are also supported learn more about Markdown Question tags: rails ×102 question asked: 12 Jul '13, 06:28