Ghost Droplet 502 Bad Gateway Error nginx/1.4.6(Ubuntu)

August 6, 2015 4k views
Ghost Nginx

I am trying to run my Ghost Droplet and made a few modifications to the config file to change the image storage system, but I'm getting a 502 Bad Gateway Error nginx/1.4.6 (Ubuntu) when I navigate to my IP address and when I run npm start via ssh method on my local terminal, it indicates that the local server is running. I'm confused as to where to start to debug this 502 Bad Gateway Error. What is possibly causing this to happen and what files should I look at?

3 comments
  • Hi Connord,

    Can you share what you changed in the config file? Also, what does sudo service ghost status return?

  • Hey @BrookDO sudo service ghost status returns ghost start/running, process 1755. Here is my config file.

    // # Ghost Configuration
    // Setup your Ghost install for various environments
    // Documentation can be found at http://support.ghost.org/config/
    
    var path = require('path'),
        config;
    
    var AWS_ACCESS_KEY = process.env.AWS_ACCESS_KEY;
    var AWS_SECRET_KEY = process.env.AWS_SECRET_KEY;
    
    
    
    config = {
        // ### Production
        // When running Ghost in the wild, use the production environment
        // Configure your URL and mail settings here
        production: {
            url: 'http://www.testsite.com',
            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: '127.0.0.1',
                // Port to be passed to node's `net.Server#listen()`, for iisnode set this to `process.env.PORT`
                port: '80'
            },
    
            storage: {
            active: 'ghost-s3',
            'ghost-s3': {
             accessKeyId: 'process.env.AWS_ACCESS_KEY',
             secretAccessKey: 'process.env.AWS_SECRET_KEY',
             bucket: 'ghost-blogpost-images',
             region: 'us-standard',
             assetHost: '//s3.amazonaws.com/ghost-blogpost-images/'
            }
            },
    
        },
    
        // ### Development **(default)**
        development: {
            // The url to use when providing links to the site, E.g. in RSS and email.
            // Change this to your Ghost blogs published URL.
            url: 'http://localhost:2368',
    
            // Example mail config
            // Visit http://support.ghost.org/mail for instructions
            // ```
            //  mail: {
            //      transport: 'SMTP',
            //      options: {
            //          service: 'Mailgun',
            //          auth: {
            //              user: '', // mailgun username
            //              pass: ''  // mailgun password
            //          }
            //      }
            //  },
            // ```
    
            database: {
                client: 'sqlite3',
                connection: {
                    filename: path.join(__dirname, '/content/data/ghost-dev.db')
                },
                debug: false
            },
            server: {
                // Host to be passed to node's `net.Server#listen()`
                host: '127.0.0.1',
                // Port to be passed to node's `net.Server#listen()`, for iisnode set this to `process.env.PORT`
                port: '2368'
            },
            paths: {
                contentPath: path.join(__dirname, '/content/')
            },
    
            storage: {
            active: 'ghost-s3',
            'ghost-s3': {
             accessKeyId: AWS_ACCESS_KEY,
             secretAccessKey: AWS_SECRET_KEY,
             bucket: 'ghost-blogpost-images',
             region: 'us-east-1',
             assetHost: '//s3.amazonaws.com/ghost-blogpost-images/'
            }
        }
    
        },
    
        // **Developers only need to edit below here**
    
        // ### Testing
        // Used when developing Ghost to run tests and check the health of Ghost
        // Uses a different port number
        testing: {
            url: 'http://127.0.0.1:2369',
            database: {
                client: 'sqlite3',
                connection: {
                    filename: path.join(__dirname, '/content/data/ghost-test.db')
                }
            },
            server: {
                host: '127.0.0.1',
                port: '2369'
            },
            logging: false
        },
    
        // ### Testing MySQL
        // Used by Travis - Automated testing run through GitHub
        'testing-mysql': {
            url: 'http://127.0.0.1:2369',
            database: {
                client: 'mysql',
                connection: {
                    host     : '127.0.0.1',
                    user     : 'root',
                    password : '',
                    database : 'ghost_testing',
                    charset  : 'utf8'
                }
            },
            server: {
                host: '127.0.0.1',
                port: '2369'
            },
            logging: false
        },
    
        // ### Testing pg
        // Used by Travis - Automated testing run through GitHub
        'testing-pg': {
            url: 'http://127.0.0.1:2369',
            database: {
                client: 'pg',
                connection: {
                    host     : '127.0.0.1',
                    user     : 'postgres',
                    password : '',
                    database : 'ghost_testing',
                    charset  : 'utf8'
                }
            },
            server: {
                host: '127.0.0.1',
                port: '2369'
            },
            logging: false
        }
    };
    
    // Export config
    module.exports = config;
    
    
  • Hi Connord,

    It looks like the section

    production: {
            url: 'http://www.testsite.com',
    

    is your culprit. When I tested my ghost install and changed to a URL that wasn't resolving to the proper IP, I also got a 502. Try replacing that URL with either a URL that is pointed at your Droplet's IP, or use the IP itself. Save, restart Ghost, and test again.

1 Answer

This question was answered by @BrookDO:

Hi Connord,

It looks like the section

production: {
       url: 'http://www.testsite.com',

is your culprit. When I tested my ghost install and changed to a URL that wasn't resolving to the proper IP, I also got a 502. Try replacing that URL with either a URL that is pointed at your Droplet's IP, or use the IP itself. Save, restart Ghost, and test again.

View the original comment

Have another answer? Share your knowledge.