simachew
By:
simachew

Ghost Error: Your site url in config.js is invalid

March 31, 2016 3.1k views
Ghost Nginx

I have created a droplet with the one click ghost app, configured /var/www/ghost/config.js /etc/nginx/sites-available/ghost with my sites url and it worked fine until I added a theme and restarted it.

Up on restart I get 502 bad gateway, I tried running npm start --production and I get the error "Error: your site url in config.js is invalid".
here is the error https://jpst.it/GFUL

I can't figure out what really is the problem. Your help is highly appreciated.

Thanks

4 comments
  • not able to see your screenshot, but best guess here is that the url parameter in your config.js is not correct. Ensure that it has the format below, including the trailing quote and comma :

        production: {
            url: 'http://<your_site>',
        ...
    
  • Thanks for the reply, @SpericalCow
    I think that is how it is already set up. Here is snippet from /var/www/ghost/config.js

    config = {
        // ### Production
        // When running Ghost in the wild, use the production environment.
        // Configure your URL and mail settings here
        production: {
            url: 'mysite.com',
            mail: {},
            database: {
                client: 'sqlite3',
                connection: {
                    filename: path.join(__dirname, '/content/data/ghost.db')
                },
                debug: false
            },
            server: {
                host: '127.0.0.1',
                port: '2368'
            }
        },
    
        // ### Development **(default)**
        development: {
            // The url to use when providing links to the site, E.g. in RSS and email.
            // Change this to your Ghost blog's 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
            // Ghost supports sqlite3 (default), MySQL & PostgreSQL
            database: {
                client: 'sqlite3',
                connection: {
                    filename: path.join(__dirname, '/content/data/ghost-dev.db')
                },
                debug: false
            },
            // #### Server
            // Can be host & port (default), or socket
            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
            // Specify where your content directory lives
            paths: {
                contentPath: path.join(__dirname, '/content/')
            }
        },
    
    
  • If I am reading the code right on ghost/core/server/config/index.js, it seems like it needs the protocol. Not sure if you have it in your config, but it should be

    http://mysite.com
    

    Otherwise, it seems like the issue happened after you had added a new theme. I don't recall any settings where I had to set a new theme with the site url, but you may want to see if the site comes up after removing the new theme. If so, there may be something wrong with the new theme.

  • http://
    

    That was what was missing. Everything works just fine now. It is weird though that it worked without at first but failed at restart. Anyway that was the problem, now it works.

    Thank you for your help.

1 Answer

Answer provided by user SphericalCow
"If I am reading the code right on ghost/core/server/config/index.js, it seems like it needs the protocol. Not sure if you have it in your config, but it should be

http://mysite.com
Otherwise, it seems like the issue happened after you had added a new theme. I don't recall any settings where I had to set a new theme with the site url, but you may want to see if the site comes up after removing the new theme. If so, there may be something wrong with the new theme."

Have another answer? Share your knowledge.