You are not logged in.
Hi
According to this I want to set my hostname in /etc/hosts file but after this I can't connect to any URL using PHP with tho following error:
getaddrinfo failed: Name or service not known
why? is it important to setting my hostname in /etc/hosts? (in Ubuntu I had this) and my hostname is not a real hostname.
Last edited by shsina (2016-10-28 11:39:41)
Offline
What does "connect to an URL using PHP" mean? What are you putting in /etc/hosts?
Moving to NC...
Offline
What does "connect to an URL using PHP" mean? What are you putting in /etc/hosts?
for example:
file_get_content('a url here')
simplexml_load_file('a url here')
and etc...
my host name is "sina-X550DP"
I am putting:
127.0.1.1 sina-X550DP.localdomain sina-X550DP
Last edited by shsina (2016-10-24 15:30:45)
Offline
localhost is 127.0.0.1
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
localhost is 127.0.0.1
All IPs which start with 127 are localhost.
Plz read topic carefully again and see URLs in it.
Offline
It seems you are correct. Sorry. Can you ping your system locally with the target being sina-X550DP? Can you ssh or http using sina-X550DP?
Trying to see if it is host name determination issues or php issues.
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
It seems you are correct. Sorry. Can you ping your system locally with the target being sina-X550DP? Can you ssh or http using sina-X550DP?
Trying to see if it is host name determination issues or php issues.
Yes I can ping and HTTP.
Without my hostname in /etc/hosts PHP works well.
In Ubuntu I had my hostname in /etc/hosts and PHP worked well. it seems it is my issue
Offline
Today after removing my hostname from /etc/hosts this problem occurred again.
I have restarted httpd from systemctl and problem fixed... It seems I need restart httpd each time after rebooting!
---
Is this cause of ordering? I mean Apache starts before NetworkManager.
Last edited by shsina (2016-10-26 14:15:53)
Offline
Apache needs your network, so it would start after NetworkManager.
Offline
Apache needs your network, so it would start after NetworkManager.
So what problem is?
Offline
Do you mean how to fix that? Edit your httpd.service and start after your Networkmanger.
Have a look at the examples in systemd wiki
Offline
Do you mean how to fix that? Edit your httpd.service and start after your Networkmanger.
Have a look at the examples in systemd wiki
My /usr/lib/systemd/system/httpd.serivce file:
[Unit]
Description=Apache Web Server
After=network.target remote-fs.target nss-lookup.target
[Service]
Type=simple
ExecStart=/usr/bin/httpd -k start -DFOREGROUND
ExecStop=/usr/bin/httpd -k graceful-stop
ExecReload=/usr/bin/httpd -k graceful
PrivateTmp=true
LimitNOFILE=infinity
KillMode=mixed
[Install]
WantedBy=multi-user.target
I think it is ok...
Offline
You should have your hostname in /etc/hosts... What are the contents of your /etc/hosts and /etc/hostname now? Throw in the output of
hostnamectl status
while you're at it
Offline
You should have your hostname in /etc/hosts... What are the contents of your /etc/hosts and /etc/hostname now? Throw in the output of
hostnamectl status
while you're at it
/etc/hostname
sina-X550DP
/etc/hosts
#
# /etc/hosts: static lookup table for host names
#
#<ip-address> <hostname.domain.org> <hostname>
127.0.0.1 localhost.localdomain localhost
127.0.1.1 sina-X550DP.localdomain sina-X550DP
::1 localhost.localdomain localhost
# End of file
hostnamectl status
Static hostname: sina-X550DP
Icon name: computer-laptop
Chassis: laptop
Machine ID: ba826b1bea3944a4af83c5ae1875daca
Boot ID: 8c0953dbf6b7488e9ae4d1a166bf8f7d
Operating System: Arch Linux
Kernel: Linux 4.8.4-1-ARCH
Architecture: x86-64
Offline
I'm not using NetworkManager, but you can try and set this in your httpd.service.
After=network.target remote-fs.target nss-lookup.target NetworkManager
Mind you, if you edit the files in '/usr/' they might be overwritten when updating systemd, best put in '/etc/'
I don't even know if this is going to work, but hey.
Offline
I'm not using NetworkManager, but you can try and set this in your httpd.service.
After=network.target remote-fs.target nss-lookup.target NetworkManager
Mind you, if you edit the files in '/usr/' they might be overwritten when updating systemd, best put in '/etc/'
I don't even know if this is going to work, but hey.
It didn't help, still need restart...
Offline
What say your logs about this?
Offline
What say your logs about this?
if you mean logs with running the systemctl status command, nothing.
Last edited by shsina (2016-10-26 15:58:55)
Offline
Look in your httpd logs for a clue, about you needing to restart it.
Offline
Look in your httpd logs for a clue, about you needing to restart it.
There is no error in there.
Last edited by shsina (2016-10-26 16:07:46)
Offline
I'm still not entirely convinced on the hostname thing, my guess is your hostname is only correctly resolved once you have a connection and as httpd starts earlier it still uses the old one and can't be accessed anymore. For reference my hosts file looks like this
#
# /etc/hosts: static lookup table for host names
#
#<ip-address> <hostname.domain.org> <hostname>
127.0.0.1 localhost.localdomain localhost arch-videl
::1 localhost.localdomain localhost arch-videl
# End of file
So I've appended my hostname to the existing localhost definitions. The 127.0.1.1 thing seems to be new and maybe something bites here.
Also if you are already customizing your unit files, iirc the correct target to wait on (until you have an actual connection) is network-online. network.target will afaik be triggered simply when your network interfaces are available, which is before you have an actual usable connection and after NetworkManager won't help either, since NetworkManager has completed its startup by then). You might also need to
systemctl enable NetworkManager-wait-online.service
so that NetworkManager will trigger network-online.target
Last edited by V1del (2016-10-27 10:59:49)
Offline
I'm still not entirely convinced on the hostname thing, my guess is your hostname is only correctly resolved once you have a connection and as httpd starts earlier it still uses the old one and can't be accessed anymore. For reference my hosts file looks like this
# # /etc/hosts: static lookup table for host names # #<ip-address> <hostname.domain.org> <hostname> 127.0.0.1 localhost.localdomain localhost arch-videl ::1 localhost.localdomain localhost arch-videl # End of file
So I've appended my hostname to the existing localhost definitions. The 127.0.1.1 thing seems to be new and maybe something bites here.
Also if you are already customizing your unit files, iirc the correct target to wait on (until you have an actual connection) is network-online. network.target will afaik be triggered simply when your network interfaces are available, which is before you have an actual usable connection and after NetworkManager won't help either, since NetworkManager has completed its startup by then). You might also need to
systemctl enable NetworkManager-wait-online.service
so that NetworkManager will trigger network-online.target
I have done all of your solutions together and separately but problem still exists...
There is nothing about this issue is google...
I didn't change any config file and I have a fresh install of Arch...
Offline
Is your hostname resolved w/o the entry in /etc/hosts? (Eg. because your router has dnsmasq and assigns it to 192.168.1.x?)
"any URL" implies www.google.com - or just your LAN?
I've localhost assigned in /etc/hosts, but not my <hostname>
For a start, i'd try to disable NM and enable netctl. NM does mess around with the hostname if it doesn't like it (famously breaking X11 if /etc/hostname is empty ...)
Offline
Also if you are already customizing your unit files, iirc the correct target to wait on (until you have an actual connection) is network-online. network.target will afaik be triggered simply when your network interfaces are available, which is before you have an actual usable connection and after NetworkManager won't help either, since NetworkManager has completed its startup by then). You might also need to
systemctl enable NetworkManager-wait-online.service
so that NetworkManager will trigger network-online.target
https://bbs.archlinux.org/viewtopic.php?id=78849
This guy had a same problem, we are in correct way, problem is cause of ordering and It seems your answer can fix it, but when I am enabling NetworkManager-wait-online service it doesn't start on boot automatically I have changed the timeout value but it doesn't start again.
Some info:
[sina@sina-X550DP ~]$ systemctl status NetworkManager-wait-online
● NetworkManager-wait-online.service - Network Manager Wait Online
Loaded: loaded (/usr/lib/systemd/system/NetworkManager-wait-online.service; d
Active: inactive (dead)
Docs: man:nm-online(1)
[sina@sina-X550DP ~]$ systemctl status network-online.target
● network-online.target - Network is Online
Loaded: loaded (/usr/lib/systemd/system/network-online.target; static; vendor
Active: inactive (dead)
Docs: man:systemd.special(7)
http://www.freedesktop.org/wiki/Software/systemd/NetworkTarget
[sina@sina-X550DP ~]$ sudo cat /usr/lib/systemd/system/NetworkManager-wait-online.service
[Unit]
Description=Network Manager Wait Online
Documentation=man:nm-online(1)
Requisite=NetworkManager.service
After=NetworkManager.service
Before=network-online.target
[Service]
Type=oneshot
ExecStart=/usr/bin/nm-online -s -q --timeout=180
RemainAfterExit=yes
[Install]
WantedBy=network-online.target
Last edited by shsina (2016-10-27 21:49:39)
Offline
Yeah that's normal, NetworkManager-wait-online target is only supposed to trigger execution of the network-online.target . What is your httpd.service pointing to now? It should have an After=network-online.target now (maybe WantedBy=network-online.target and Wants=network-online.target as well) and remove the references to NetworkManager there. Don't hang yourself up on that DAEMONS line, that's for pre-systemd configuration.
Last edited by V1del (2016-10-28 11:32:30)
Offline