[Solved] mpd error: Connection refused

Everything about X, Gnome, KDE, ... and everything running on it

[Solved] mpd error: Connection refused

Postby bester69 » 2018-12-09 10:58

Hi,

Im getting this error with mpc client, Im using mpd as not a daemon service ..

Do you know how to use (connect) mpc with mpd as not a service? :?

My /etc/mpd.conf

music_directory "/home/myuser/Música/"
playlist_directory "/home/myuser/.mpd/playlists"
db_file "/home/myuser/.mpd/tag_cache"
log_file "/home/myuser/.mpd/mpd.log"
pid_file "/home/myuser/.mpd/pid"
state_file "/home/myuser/.mpd/state"
sticker_file "/home/myuser/.mpd/sticker.sql"
user "myuser"
bind_to_address "192.168.1.128"

audio_output {
type "pulse"
name "My Pulse Output"
device "/dev/dsp"
mixer_type "hardware"
}


Thanks.
Last edited by bester69 on 2018-12-11 11:40, edited 1 time in total.
bester69 wrote:You wont change my mind when I know Im right, Im not an ...
User avatar
bester69
 
Posts: 1413
Joined: 2015-04-02 13:15

Re: mpd error: Connection refused

Postby shep » 2018-12-09 20:10

You will get that message if mpd is not running. Usually it fails to start due to a missing or incorrect mpd config file.
Also be aware that Debian will enable mpd.service with mpd installation. You can disable it with
Code: Select all
# systemctl disable mpd.service


The mpd version is a little dated in Debian 9 and by default only looks at configuration files in
FILES
~/.mpdconf
User configuration file.

/etc/mpd.conf
Global configuration file.

Since you did not make an ~/.mpdconf, and did not specify disabling mpd.service, you may have mpd trying to use the playlist and Music directories specified in /etc/mpd.conf. It will basically fail to start and output the results to mpd.log (where ever that is).
You can specify the config file when you start mpd by
Code: Select all
$ mpd /path/to/mpd.conf

.
My ~/.config/openbox/autostart
Code: Select all
# Start volume system tray applet
(sleep 2.5 && volumeicon) &
# Start Tint2 dock
(sleep 3.0 && tint2 -c ~/.config/tint2/launcher.tint2rc) &
# Start MPD
(sleep 3.5 && mpd ~/.config/mpd/mpd.conf)

If you do this from the command line, any errors in the config file will be output.
An alternative is to set up a unix socket for mpd. The Arch Linux mpd wiki is a good guide for setting up an mpd socket.
Last edited by shep on 2018-12-12 13:55, edited 2 times in total.
shep
 
Posts: 305
Joined: 2011-03-15 15:22

Re: mpd error: Connection refused

Postby bester69 » 2018-12-10 19:29

Hi shep,

First, thanks a lot for you help :)

I shoud tell you My mpd is working well, only mpc client isnt able to connect to mpd, see music directories such as I posted in my mpd.conf (im using Cantata and others graphicall clients), but mpc client keeps reporting that message.. I need a command client (mpc) in order to pause or stop music within a script or perhaps you know a better way or Workaround to get this and let mpd proccess running at the same time.

I disabled service and also copy mpf.conf to home and mpc still giving that problem,.. I tried to find a solution to this problem on google, but i wasnt able..

I want Stop/Pause Music before killing mpd, so when I lauched mpd back It doesnt play the previous music.

#!/bin/bash
#
killall mpd
killall cantata &
sleep 1
killall cantata -9
mpd
cantata
mpc stop/pause/toggle <<<<<<<<<<<<<<<<< I need this :idea:
killall mpd
bester69 wrote:You wont change my mind when I know Im right, Im not an ...
User avatar
bester69
 
Posts: 1413
Joined: 2015-04-02 13:15

Re: mpd error: Connection refused

Postby shep » 2018-12-10 21:40

I usually use ncmpc with a unix socket.

https://linux.die.net/man/1/mpc

-h,--host
The host to connect to; if not given, the value of the environment variable MPD_HOST is checked before defaulting to localhost. This default can be changed at compile-time.
To use a password, provide a value of the form "password@host".

If you specify an absolute path, mpc attempts a connection via Unix Domain Socket.

-p,--port
The port to connect to; if not given, the value of the environment variable MPD_PORT is checked before defaulting to 6600. This default can be changed at compile-time.


You may need to specify your host and port with mpc

Code: Select all
mpc -h 192.168.1.128


You also may be able to set MPD_HOST=192.168.1.128 in your script environment
shep
 
Posts: 305
Joined: 2011-03-15 15:22

[Solved] Re: mpd error: Connection refused

Postby bester69 » 2018-12-11 11:38

shep wrote:
If you specify an absolute path, mpc attempts a connection via Unix Domain Socket.

-p,--port
The port to connect to; if not given, the value of the environment variable MPD_PORT is checked before defaulting to 6600. This default can be changed at compile-time.
You may need to specify your host and port with mpc

Code: Select all
mpc -h 192.168.1.128


You also may be able to set MPD_HOST=192.168.1.128 in your script environment

Ok, Thanks a lot Shep, have a nice day :o

both thinks made it work:
mpc -h 192.168.1.128 stop
or
export MPD_HOST=192.168.1.128 && mpc stop
bester69 wrote:You wont change my mind when I know Im right, Im not an ...
User avatar
bester69
 
Posts: 1413
Joined: 2015-04-02 13:15


Return to Desktop & Multimedia

Who is online

Users browsing this forum: No registered users and 13 guests

fashionable