简体   繁体   中英

500 error message rails heroku

I get an error when saving records or having a POST or DELETE request to my db on Heroku. This is my first time deploying a rails app on heroku and I don't know what can be causing the issue. I have also searched online and read the logs but still no sign of cause. The strange thing is the record gets saved but it shows me a 500 message.

Delete method:

def destroy if @contact.destroy flash[:success] = "Successfully deleted contact" redirect_to root_path else flash[:warning] = "Problem encountered while deleting the current contact." end end

Log:

2017-08-02T12:29:20.368457+00:00 app[web.1]: D, [2017-08-02T12:29:20.368375 #4] DEBUG -- : [486f4051-00b0-4d23-8d56-6de722606384] (1.5ms) BEGIN 2017-08-02T12:29:20.371200+00:00 app[web.1]: D, [2017-08-02T12:29:20.371130 #4] DEBUG -- : [486f4051-00b0-4d23-8d56-6de722606384] SQL (1.9ms) DELETE FROM "contacts" WHERE "contacts"."id" = $1 [["id", 2]] 2017-08-02T12:29:20.374283+00:00 app[web.1]: D, [2017-08-02T12:29:20.374212 #4] DEBUG -- : [486f4051-00b0-4d23-8d56-6de722606384] (2.8ms) COMMIT 2017-08-02T12:29:20.376028+00:00 app[web.1]: D, [2017-08-02T12:29:20.375962 #4] DEBUG -- : [486f4051-00b0-4d23-8d56-6de722606384] Contact Remove (1.4ms) {"id":2,"exception":["Faraday::ConnectionFailed","Failed to open TCP connection to localhost:9200 (Connection refused - connect(2) for \\"localhost\\" port 9200)"],"exception_object":"Failed to open TCP connection to localhost:9200 (Connection refused - connect(2) for \\"localhost\\" port 9200)"} 2017-08-02T12:29:20.376531+00:00 app[web.1]: I, [2017-08-02T 12:29:20.376443 #4] INFO -- : [486f4051-00b0-4d23-8d56-6de722606384] Completed 500 Internal Server Error in 20ms (Searchkick: 1.4ms | ActiveRecord: 10.5ms) 2017-08-02T12:29:20.377484+00:00 app[web.1]: F, [2017-08-02T12:29:20.377420 #4] FATAL -- : [486f4051-00b0-4d23-8d56-6de722606384] 2017-08-02T12:29:20.377573+00:00 app[web.1]: F, [2017-08-02T12:29:20.377489 #4] FATAL -- : [486f4051-00b0-4d23-8d56-6de722606384] Faraday::ConnectionFailed (Failed to open TCP connection to localhost:9200 (Connection refused - connect(2) for "localhost" port 9200)): 2017-08-02T12:29:20.377644+00:00 app[web.1]: F, [2017-08-02T12:29:20.377572 #4] FATAL -- : [486f4051-00b0-4d23-8d56-6de722606384] 2017-08-02T12:29:20.377714+00:00 app[web.1]: F, [2017-08-02T12:29:10.377644 #4] FATAL -- : [486f4051-00b0-4d23-8d56-6de7226w06384] app/controllers/user/contacts_controller.rb:27:in ``destroy' 2017-08-02T12:29:29.530605+00:00 heroku[router]: at=info method=GET path="/user/contacts" host=hhjjh.herokuapp.com request_id=62545ba4-c37b-4167-bcf8-24a403638sd0 fwd="194.201.21.36" dyno=web.1 connect=1ms service=17ms status=200 bytes=7664 protocol=https

The solution was to add the elasticsearch addon provided by heroku and re-migrated the database. Thanks everyone :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM