samedi 11 novembre 2017

Unexpected 500 Internal Server Error with Laravel API to a Database to which I have full access

I've followed the following two tutorials on making a simple API with Laravel:

Build a React App With a Laravel RESTful Back End: Part 1, Laravel 5.5 API

Laravel API Tutorial: How to Build and Test a RESTful API

The tutorials are great and I am using a remote database hosted at Siteground from which the API should grab the responses. This database is fine for seeding data etc as described in the tutorials but whenever I use Postman (or curl for that matter) like so, with the Accept : application/json header enabled:

localhost:8000/api/products (first tutorial) I get the following 500 Internal Server Error:

{ "message": "SQLSTATE[HY000] [2002] Connection refused (SQL: select * fromproducts)", "exception": "Illuminate\\Database\\QueryException", "file": "/Users/davechambers/Documents/Dev/satNight/vendor/laravel/framework/src/Illuminate/Database/Connection.php", "line": 664, "trace": [ { "file": "/Users/davechambers/Documents/Dev/satNight/vendor/laravel/framework/src/Illuminate/Database/Connection.php", "line": 624, "function": "runQueryCallback", "class": "Illuminate\\Database\\Connection", "type": "->" },................etc etc .........

Ok, so the message is clear:

SQLSTATE[HY000] [2002] Connection refused ... but why?

My Laravel app already has access to the database and at Siteground as does the rest of the Internet as I have the Remote Database Access Hosts set to %.

Can anybody shed any light on why I'm getting this 500 Internal Server Error as it's driving me nuts!

Please note, this is NOT a duplicate of the multitude of laravel SQLSTATE[HY000] [2002] Connection refused questions and solutions.



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2hsnQay
via IFTTT

1 commentaire: