LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 03-08-2021, 11:49 PM   #1
rnturn
Senior Member
 
Registered: Jan 2003
Location: Illinois (SW Chicago 'burbs)
Distribution: openSUSE, Raspbian, Slackware. Previous: MacOS, Red Hat, Coherent, Consensys SVR4.2, Tru64, Solaris
Posts: 2,803

Rep: Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550
Problem getting Nginx started on Raspbian


I have a Raspberry Pi running as the Bind server and Nginx server (reverse proxy) on our home LAN. Version: "Raspbian GNU/Linux 9 (stretch)"

Upon booting, Nginx will not start. I've enabled it using systemctl and after rebooting Nginx's error log contains:
Code:
[emerg] 798#798: host not found in upstream "testhost.internal-domain:80" in /etc/nginx/sites-enabled/testhost.internal-domain.conf:5
which, to me, looks like it's not waiting for Bind to be run.

By the time I can get logged in and verify that Nginx is not running, manually executing "/etc/init.d/nginx start" works as it should.

The service file in /lib/systemd/system contains:
Code:
Description=A high performance web server and a reverse proxy server
Documentation=man:nginx(8)
After=network.target
...
which I changed to be:
Code:
Description=A high performance web server and a reverse proxy server
Documentation=man:nginx(8)
Requires=bind9.service
After=bind9.service
#After=network.target
...
Since "bind9.service" had the same "After=" record, my plan was to let bind wait for the network, than have nginx wait for bind.

I commented out the "After=network.target" record since it seemed logical it seemed logical that, if bind waited for network.target, nginx could simply wait for bind.

After running "systemctl daemon-reload" and booting, though, the same result. Same error message in Nginx's error log. Systemd shows that the nginx service is enabled.

/var/log/syslog contains the error messages:
Code:
nginx[819]: nginx: [emerg] bind() to 192.168.13.178:80 failed (99: Cannot assign requested address)
nginx[819]: nginx: configuration file /etc/nginx/nginx.conf test failed
systemd[1]: nginx.service: Control process exited, code=exited status=1
systemd[1]: Failed to start A high performance web server and a reverse proxy server.
systemd[1]: nginx.service: Unit entered failed state.
systemd[1]: nginx.service: Failed with result 'exit-code'.
Running "nginx -t", "/etc/init.d/nginx configtest", etc. show no problems with the nginx configuration file.

At this point, I've restored the service file using the pre-tweak backup file.

Summary:

At boot: Starting it within Systemd? Does not start nginx.

After boot: "system nginx start"? Starts nginx

After boot: "systemctl start nginx.service"? Starts nginx

... and everything seems to be working after issuing any of the manual commands. (Accessing web sites from the internet does get to the actual servers listening on 8080, etc.)


Ideas as to where to look next?


(I'm trying really hard to be friends with Systemd but every time I encounter a problem with it, I'm seriously tempted to search out a Systemd-free OS for the Pi.)


TIA...

Last edited by rnturn; 03-09-2021 at 09:09 AM. Reason: spelling error
 
Old 03-09-2021, 08:41 PM   #2
pdean712
LQ Newbie
 
Registered: Dec 2008
Posts: 18

Rep: Reputation: 1
Code:
nginx[819]: nginx: [emerg] bind() to 192.168.13.178:80 failed (99: Cannot assign requested address)
This emergency error looks to be related to you starting nginx before networking was started...i would try making sure nginx starts After: both networking and bind.

Maybe something like the below:
Code:
After=network.target bind9.service

Last edited by pdean712; 03-09-2021 at 08:44 PM.
 
1 members found this post helpful.
Old 03-10-2021, 09:07 PM   #3
rnturn
Senior Member
 
Registered: Jan 2003
Location: Illinois (SW Chicago 'burbs)
Distribution: openSUSE, Raspbian, Slackware. Previous: MacOS, Red Hat, Coherent, Consensys SVR4.2, Tru64, Solaris
Posts: 2,803

Original Poster
Rep: Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550
Quote:
Originally Posted by pdean712 View Post
Code:
nginx[819]: nginx: [emerg] bind() to 192.168.13.178:80 failed (99: Cannot assign requested address)
This emergency error looks to be related to you starting nginx before networking was started...i would try making sure nginx starts After: both networking and bind.

Maybe something like the below:
Code:
After=network.target bind9.service
Tried that. No joy. Same error:
Code:
[emerg] bind() to 192.168.13.178:80 failed (99: Cannot assign requested address)
I can start/stop nginx all day long... by hand. "service nginx start", "systemctl nginx start". "/etc/init.d/nginx start"... those all work. It's just Systemd that can't at boot time.

Aha!

I realized that I had troubles getting nginx up and running last summer. The fix at that time was to alter the Unit definition to be:
Code:
[Unit]
#After=network.target
After=multi-user.target

[Install]
#Wants=multi-user.target
It appears that a recent update clobbered that change.

I'll mark this as "solved".
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Raspbian (Stretch): systemd not starting nginx rnturn Linux - Embedded & Single-board computer 2 07-12-2020 08:46 AM
LXer: Raspbian GNU/Linux upgrade from Stretch to Raspbian Buster 10 LXer Syndicated Linux News 0 07-26-2019 06:12 PM
LXer: Raspbian GNU/Linux upgrade from Jessie to Raspbian Stretch 9 LXer Syndicated Linux News 0 03-01-2018 07:50 PM
LXer: Raspbian GNU/Linux upgrade from Wheezy to Raspbian Jessie 8 LXer Syndicated Linux News 1 06-09-2016 12:12 PM
Nginx experts help me-problem when using Nginx php-fpm !!! HuMan-BiEnG Linux - Server 2 04-17-2011 02:30 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 09:05 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration