Ghost, Nginx, 502, and Port Problems

May 9, 2014 3.5k views
Got myself into a problem trying to install Ghost 0.4.2 on a Digital Ocean Droplet with node 0.10. I used the Dokku Droplet (instead of their Ghost setup) because I'd like to install multiple node apps with different domains. I git cloned the stable Ghost release and followed the instructions they gave to set it up: npm install -g grunt-cli npm install grunt init (and grunt prod if you want to run Ghost in production mode) npm start I've changed my config.js file (the production part) to url: '', mail: {}, database: { client: 'sqlite3', connection: { filename: path.join(__dirname, '/content/data/ghost.db') }, debug: false }, server: { // Host to be passed to node's `net.Server#listen()` host: '', // Port to be passed to node's `net.Server#listen()`, for iisnode set this to `process.env.PORT` port: '2368' When I use port 2368, it says that "Ghost is running... Your blog is now available on" But then it gives me a 502 error. Ok, when I change the production port to 80 (one article suggested this), it throws this error: events.js:72 throw er; // Unhandled 'error' event ^ Error: listen EADDRINUSE at errnoException (net.js:901:11) at Server._listen2 (net.js:1039:14) at listen (net.js:1061:10) at net.js:1143:9 at dns.js:72:18 at process._tickDomainCallback (node.js:459:13) at process._tickFromSpinner (node.js:390:15) npm ERR! weird error 8 npm WARN This failure might be due to the use of legacy binary "node" npm WARN For further explanations, please read /usr/share/doc/nodejs/README.Debian I'm guessing this means that port is already in use. Ok, so here's another part I don't understand. Many sites mention trying "sudo service ghost restart". I always get "ghost: unrecognized service" to this. It's odd because everything is in place and the developer instructions they gave (see the top of this) worked well for installing it. But my system doesn't know it's there. Also, there doesn't seem to be any /var/www/ghost file. Not sure what that means. I've sleuthed and googled but can't seem to figure this out. Any hints or tips would be so appreciated.
4 Answers
If you're not actually using Dokku to deploy the Ghost blog, I'd suggest using a standard Ubuntu image. The "Error: listen EADDRINUSE" error you're seeing when you set the port to 80 is because nginx is already listening on port 80.

When you set the port to 2368, can you access the blog at:

If so, you just need to set up an Nginx server block:

server {
listen 80 default_server;

root /usr/share/nginx/html;
index index.html index.htm;

# Make site accessible from http://localhost/

location / {
proxy_pass \htp://localhost:2368/;
proxy_set_header Host $host;
proxy_buffering off;

Add that to something like "/etc/nginx/sites-enabled/default"
Ok thanks. Will that work if I use Dokku as well? It seems like Dokku is a good idea for having multiple apps on one VPS.
It should. Dokku generates nginx configs for each app that are similar. It uses random ports, so the only problem I could imagine is if it randomly picked that port...
Ok, thanks very much Andrew for your help.
Have another answer? Share your knowledge.