xdg-open : no method available even after installing xdg-utils

Neo picture Neo · Jul 10, 2014 · Viewed 31.7k times · Source

I am using generator-angular-fullstack. On my local machine its working fine, I run

 grunt serve

it starts server but in VPS it's failing

Warning: Command failed: xdg-open: no method available for opening 'http://localhost:9000'

and I have already installed xdg-utils

 $ sudo apt-get install xdg-utils
 Reading package lists... Done
 Building dependency tree       
 Reading state information... Done
 xdg-utils is already the newest version.

Can any one explain me what I am doing wrong?

Answer

user2363448 picture user2363448 · Jul 24, 2014

Have you tried configuring the xdg-open handlers?

Also, have you ensured you have a browser installed on your server? Installing a new browser with apt-get install <browser> should automatically make xdg-open aware of it. However, your setup may not have done this depending on the order that your browser/xdg-utils were installed.

To make things sane again requires running xdg-settings.

To set an http:// handler to your preferred browser (which on a headless server is likely to be w3m, lynx or elinks), do the following:

xdg-settings set default-web-browser w3m.desktop

To verify, you can run xdg-open https://stackoverflow.com/questions/24683221 and you should see your answer in w3m.

If you don't have w3m available, install it with sudo apt-get install w3m

You may wish to see other available handlers by running xdg-settings --list, which on my system, outputs the following:

Known properties:
  default-url-scheme-handler    Default handler for URL scheme
  default-web-browser           Default web browser

EDIT: It turns out that some old systems (ubuntu 10.04) don't have xdg-settings, and that the update-alternatives command should automatically configure xdg-open. Like so:

    sudo update-alternatives --config www-browser