You are not logged in.

#1 2014-01-24 17:36:47

Luckiboy
Member
Registered: 2013-11-22
Posts: 15

[Solved] Cups error (/etc/hosts corrupt?)

Hi all,

I have got a problem with cups. When I try to print, it says "Filter failed", and the web interface (localhost:631) is unreachable, it says "Bad request". I think it has something to do with my /etc/hosts configuration, but I haven't found the exact problem yet. This is my /etc/hosts:

#
# /etc/hosts: static lookup table for host names
#

# Local
127.0.0.1  localhost.localdomain    localhost
::1        localhost.localdomain    localhost

# Filters
127.0.0.1 www.google-analytics.com
127.0.0.1 ssl.google-analytics.com
127.0.0.1 google-analytics.com
127.0.0.1 www.googleadservices.com
127.0.0.1 googleadservices.com
127.0.0.1 cnbc7.com

# End of file

Any suggestions?

Last edited by Luckiboy (2014-01-26 17:34:43)

Offline

#2 2014-01-25 12:04:06

Spider.007
Member
Registered: 2004-06-20
Posts: 1,175

Re: [Solved] Cups error (/etc/hosts corrupt?)

I find it hard to believe you hosts file would be corrupted, and the file you post seems fine. Have a look at the cups log and tell us what it says when it outputs 'Bad request'.

Offline

#3 2014-01-25 15:21:34

Luckiboy
Member
Registered: 2013-11-22
Posts: 15

Re: [Solved] Cups error (/etc/hosts corrupt?)

The log file says localhost:631 is an invalid host? Besides, I frequently see the error "Unable to bind socket for address 0.0.0.0:631 - Address already in use.", and when I go to 127.0.0.1:631 my browser says Forbidden. I don't get it. :\

Offline

#4 2014-01-26 09:11:36

Luckiboy
Member
Registered: 2013-11-22
Posts: 15

Re: [Solved] Cups error (/etc/hosts corrupt?)

I found out that when I uninstall cups, remove /etc/cups and /var/spool/cups and install cups again, I have access to localhost:631. However, when I reboot I no longer have access. Does the cups configuration change when I reboot?

Offline

#5 2014-01-26 12:12:47

Spider.007
Member
Registered: 2004-06-20
Posts: 1,175

Re: [Solved] Cups error (/etc/hosts corrupt?)

"Address already in use" means there is some other application already bound to that port. What does this output after rebooting?

sudo ss -lpn|grep 631

. Also the wiki tells you to run `hostname` and use that hostname instead of localhost, did you try that?

Offline

#6 2014-01-26 12:31:10

Luckiboy
Member
Registered: 2013-11-22
Posts: 15

Re: [Solved] Cups error (/etc/hosts corrupt?)

sudo ss -lpn|grep 631

returns:

tcp    LISTEN     0      128                   :::631                  :::*      
users:(("cupsd",1410,4),("systemd",1,34))

Also, I already tried replacing "localhost" with my hostname, but again, I got a Forbidden error.

Offline

#7 2014-01-26 13:19:29

Spider.007
Member
Registered: 2004-06-20
Posts: 1,175

Re: [Solved] Cups error (/etc/hosts corrupt?)

Okay so cups already start on booting, which is fine. However, cups listens to ipv6 traffic only and I think when starting cups, the access configuration defines only ipv4 traffic as allowed. To make sure this is the problem, update your cupsd.conf and replace Listen localhost:631 with Listen 631. If that works, I would strongly suggest updating that to Listen [::1]:631, because otherwise you are granting the (potentially) entire world access to your cups configuration

Last edited by Spider.007 (2014-01-26 13:19:47)

Offline

#8 2014-01-26 13:45:23

Luckiboy
Member
Registered: 2013-11-22
Posts: 15

Re: [Solved] Cups error (/etc/hosts corrupt?)

Ok, so I replaced "Listen localhost:631" with "Listen 631", restarted cups, but it is not working... I still get a Bad request error on localhost:631 and a Forbidden error on 127.0.0.1:631.
Full log:

E [26/Jan/2014:14:38:00 +0100] Unable to bind socket for address [v1.::1]:631 - Address already in use.
E [26/Jan/2014:14:38:06 +0100] [Client 13] Request from "[v1.::127.0.0.1]" using invalid Host: field "localhost:631"
E [26/Jan/2014:14:38:06 +0100] [Client 13] Request from "[v1.::127.0.0.1]" using invalid Host: field "localhost:631"
E [26/Jan/2014:14:38:07 +0100] [Client 13] Request from "[v1.::127.0.0.1]" using invalid Host: field "localhost:631"
E [26/Jan/2014:14:38:07 +0100] [Client 13] Request from "[v1.::127.0.0.1]" using invalid Host: field "localhost:631"

Offline

#9 2014-01-26 16:11:43

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 19,796

Re: [Solved] Cups error (/etc/hosts corrupt?)

Which browser are you using?  I am surprised you are getting a 403 error (Forbidden).  I would expect you might get a 401 (Unauthorized) if your request were making it all the way to cups.
What log is that you shared in post #8?


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way

Offline

#10 2014-01-26 16:26:01

Luckiboy
Member
Registered: 2013-11-22
Posts: 15

Re: [Solved] Cups error (/etc/hosts corrupt?)

Which browser are you using?

Primarily Firefox. I just went to localhost:631 with Google Chrome, and there it works. Weird. So it's just Firefox? I'll remove .mozilla after I synced my config, I'll notice you when that solved it.

What log is that you shared in post #8?

/var/log/cups/error_log

Offline

#11 2014-01-26 17:34:21

Luckiboy
Member
Registered: 2013-11-22
Posts: 15

Re: [Solved] Cups error (/etc/hosts corrupt?)

Yeah! It is working! So what I did is removing the .mozilla directory, and it's working now. I think I incidentally disabled ipv6, but because I wasn't sure I chose the "hard" way and reset firefox (by removing .mozilla). Thank you all for help!

Offline

#12 2014-02-09 20:14:05

jwhendy
Member
Registered: 2010-04-01
Posts: 621

Re: [Solved] Cups error (/etc/hosts corrupt?)

I was having a similar issue on my work computer, which I solved by another thread's suggestion to make sure /etc/hosts had an ipv6 line. This worked on my work computer (uncommented the ipv6 line and could get to localhost:631 again), but my home computer was fine, even with my ipv6 line still commented. I just updated another post with the possible source of the issue, a ListenStream=631 line in /usr/lib/systemd/system/cups.socket, which did not exist in the 1.7.0 version of cups. The 1.7.1 version was pushed out sometime last month, which might explain these posts only coming up now (there's at least three). Read more via my post in the other thread.

I know this is marked solved, but others may stumble on it and the .mozilla folder might not be the issue (mine was browser-independent), so I'm leaving breadcrumbs in related posts.

Offline

#13 2014-02-09 21:47:48

jwhendy
Member
Registered: 2010-04-01
Posts: 621

Re: [Solved] Cups error (/etc/hosts corrupt?)

For any interested, I was going to post a bug report, but in searching first, one had already been filed back on 1/27. I added links to the three pertinent threads there and will be following along.

Offline

#14 2014-03-04 02:47:52

twelveeighty
Member
From: Alberta, Canada
Registered: 2011-09-04
Posts: 1,096

Re: [Solved] Cups error (/etc/hosts corrupt?)

I'm not sure if Google will pick up this reply for those searching for a solution, but I found another symptom of this same problem is a completely different area: printing from a Java application, including Java Web Start applets. When trying to print, you will get an error dialog thrown from inside the Java Print Service API: "No print service found". Applying the same fix: removing or commenting out ListenStream=631 in cups.socket resolves that problem as well.

Interestingly enough, I did NOT have the other posted problems where localhost:631 wasn't accessible. It was only printing from a Java app that was affected in my case. Both the OpenJRE and Oracle JRE had this problem.

Offline

#15 2014-03-04 03:09:23

jwhendy
Member
Registered: 2010-04-01
Posts: 621

Re: [Solved] Cups error (/etc/hosts corrupt?)

@twelveeighty: did you have ipv6 enabled (no kernel line in your bootloader disabling it) and an ipv6 address in /etc/hosts and still get the issue?

Offline

#16 2014-03-04 04:05:01

twelveeighty
Member
From: Alberta, Canada
Registered: 2011-09-04
Posts: 1,096

Re: [Solved] Cups error (/etc/hosts corrupt?)

jwhendy wrote:

@twelveeighty: did you have ipv6 enabled (no kernel line in your bootloader disabling it) and an ipv6 address in /etc/hosts and still get the issue?

Short answer: yes, I do *not* have a kernel line in grub disabling ipv6 and I *do* have an ipv6 address in /etc/hosts and Java printing did not work until I commented out ListenStream in cups.socket. However, the original reported problem of localhost:631 not working was not an issue for me: printing worked fine and the CUPS web interface also worked. It was only printing from a Java app that was broken.

Offline

#17 2014-03-04 14:22:26

R00KIE
Forum Fellow
From: Between a computer and a chair
Registered: 2008-09-14
Posts: 4,734

Re: [Solved] Cups error (/etc/hosts corrupt?)

With IPv4 only (ipv6 disabled) it seems to work fine for me, at least printing from openproj which is a java program. I'll edit this post later after I have a chance to try with ipv6 enabled.

Edit:
I've done a few tests and I'm inclined to blame this on systemd.

Test with ipv4 only:
Everything works as expected.

Test with ipv6 enabled:
Everything seems to work fine but something is not right, systemd should bind to ipv6 _and_ ipv4, I've tried to explicitly configure that with "BindIPv6Only=both" in the socket file but systemd only seems to bind to ipv6, at least according to the output of ss.

When systemd is configured to bind to ipv6 and ipv4 it also seems to prevent cups from binding to port 631 on ipv4, if using "BindIPv6Only=ipv6-only" then systemd leaves ipv4 alone and cups can bind to either 127.0.0.1:631 or *:631 (depends on cups configuration).

Most programs work properly because I suppose they try ipv6 first and if that fails they fall back to ipv4. In the case of java programs I guess they don't even bother with ipv6. At least openproj can't find any printers unless cups is listening on ipv4 port 631, the funny thing is that if cups is stopped, when opening the print preview where the printer can be selected, cups is started automatically.

Last edited by R00KIE (2014-03-04 17:49:28)


R00KIE
Tm90aGluZyB0byBzZWUgaGVyZSwgbW92ZSBhbG9uZy4K

Offline

#18 2014-03-04 19:09:35

jwhendy
Member
Registered: 2010-04-01
Posts: 621

Re: [Solved] Cups error (/etc/hosts corrupt?)

@twelveeighty: Gotcha, and thanks for clarifying. So it's java + cups only, then. Just wanted to make sure, as I've been commenting on some bug reports about this.

@R00KIE: I played with the BindIPv6Only setting as well, which I commented on in this bug report. Ultimately, I didn't need that, but it sounds like java is behaving differently. Re. the auto-start behavior when you opened the print dialog, it was mentioned at the bug report at that the purpose of ListenStream=631 was for the purpose of auto-starting cups.service if localhost:631 was accessed if cups.socket is running already. That's been my experience as well. I can just have cups.socket, and once I access cups (print/web interface), cups.service is started up as well.

Offline

Board footer

Powered by FluxBB