Cannot access raspberry pi with static ip

When you ping a device on the same subnet it should send it directly to the addressed device. The gateway address is irrelevant. That is why we need more information showing how the pi is configured, and what request the PC is sending when it pings it. As @gerry says it is either bad hardware or misconfigured device.

I shall relinquish to your knowledge.

But he hasn't really answered my questions with clear indications of what happens with what.

First of all I carry my IP set into 192.168.150 block.

Node-red is running on rpi. In Rpi I can access node-red . SSH is enabled.

You haven't clarified what happens if you have a switch between the devices and what happens with the router .

When I use switch I cannot access RPi in any way. I can just see ip address of rpi on IP Scanner program but when I tried to ping it it doesn't respond. when I use router I can access node-red from my PC

On rpi side
https://ibb.co/y4J6KGX

I guess my switch is non-managed. It says 10/100Mbps Desktop Switch

There is no uplink else where.

There is a detail that get my attention. I plug my devices into switch and I connect switch to router via ethernet cable. System worked. and then I remove router, system continued to work without problem. This problem pops up whenever system starts without router.

That is a bit strange.

A router is used when you are using different IP ranges and need to connect them.
There is a local side and the uplink which gets any IP addresses which are outside the local range.

So, using a program to show the rpi's IP is active doesn't really mean much - to me.

If the rpi is plugged in, you should be able to ping it. Switch or Router.

With the switch plugged into the rpi:
open a CLI (terminal) and enter the command:
sudo ifconfig

What do you see? Is eth0 set to the correct IP address?

Can you ping the pc from the rpi?
Just to see if it works the other way.

eth0: inet 192.168.150.10 netmask: 255.255.255.0 broadcast 192.168.150.255

When I try to ping from pc to rpi or vice versa, doesn't respond to each other

It seems that one of the devices does not like starting up without a router. To find which:

  1. Connect up with switch and router and check everything works.
  2. Remove router and check still works.
  3. Reboot the PC and see what happens.

Then repeat, 1, 2 and then reboot the Pi instead.

Finally repeat 1 and 2 then power cycle the switch.

One other thing you could try:
(Sorry @Colin)

The router must have an IP address.

See if you can ping the router from either/both machines.

To keep things followable:
The switch between the two machines does not work.
The router between the two machines works - but I saw you were posting some conditionality about that.

Get the rpi or the pc.... connect which ever to the router.
Ping the router and get it working to that point.
Plug the other machine in.
Ping between the two machines.

This makes sure that you have a working IP connection.

With that working, unplug one of the machines: (rpi or pc)
put the switch between the router and the just unplugged device.

From that device, see if you can ping the router.
I am suspicious the switch is broken.
If it doesn't work, you can play swap ports on the switch and see if you can find two working ports - if you want to spend the time doing that.

But if when you put the switch between the router and a device, and the device can no longer ping the router, I'd say the switch is the problem.

It does, provided the switch is also connected to the router upstream. The hardware works, and continues to work even if the router is removed. One of the devices does not like booting with no gateway connected.

Something else to check is to look in syslog on the pi after booting with no router and see what it says about networking.

I tried what you said. First 3 step are successful. I reboot my pc there is no problem I can connect to rpi.I reboot rpi and then rpi turned out unreachable again. It seems I have a problem with rpi.

I also tried after removing router then I unplug ethernet cable of Rpi then plug it , Again I cannot access Rpi.

Is the router connected to the internet? If so then try the tests with it not connected to the internet.

Otherwise:

Repeat that sequence but then before pugging it back in run, in a terminal,
tail -f /var/log/syslog
and then plug it in and see what it says. That assumes you have a keyboard and display on the pi of course.

There is no internet connection in network.

Yes I have them. I wrote that piece of code, output :

dhcpcd [502 ] : eth0: received approval for 192.168.150.10
dhcpcd [502 ] : eth0: received approval for 192.168.150.10
dhcpcd [502 ] : eth0: received approval for 192.168.150.10
dhcpcd [502 ] : eth0: received approval for 192.168.150.10
dhcpcd [502 ] : eth0: received approval for 192.168.150.10
dhcpcd [502 ] : eth0: received approval for 192.168.150.10
dhcpcd [502 ] : eth0: received approval for 192.168.150.10
dhcpcd [502 ] : eth0: received approval for 192.168.150.10
dhcpcd [502 ] : eth0: received approval for 192.168.150.10
dhcpcd [502 ] : eth0: received approval for 192.168.150.10

says just ten times.

looks like the router is also serving out dhcp addresses - which the switch would not do - so the device that needs a dhcp address isn't getting one from the switch only config and thus can't ping.

Yes just as you said. looks like something has to serve out dhcp address in the network or else devices are not be able to recognize each other

Edit: After 20 min of writing syslog code, another 2 line of info appears like :

dhcpcd[502] : eth0 : deleting route to 192.168.150.0/24
dhcpcd[502] : eth0 : deleting default route via 192.168.150.1

If he can ping in one configuration then not in another that suggests his hardware is operational unless there is an intermittent failure of some sort. If indeed everything has a fixed ip the DHCP is irrelevant. As @dceejay points out something is trying to configure via DHCP so somewhere there is a misconfiguration of his fixed ip's. If he truly has a switch/hub available then for his local network there is no need for the router at all. I would take it out put it on a shelf, lock the door and leave it alone. Set the default gateway to the pi's ip address so everything on the network gets routed there first, triple check the ip settings that everything is set to fixed ip's and have another go. As a suggestion go with pi address, 192.168.1.100 subnet class C 255.255.255.0, default gateway 192.168.1.100,--- pc 192.168.1.101 subnet 255.255.255.0, default gateway 192.168.1.100, any other devices increment ip addresses up one number but point everything at the pi's address for a default gateway. No router, no internet, wireless turned off. And wear a tin foil hat just in case, kidding about the hat. But seriously make sure all wireless is off as that could grab a spurious ip address and route your packets somewhere else, no bluetooth either if so equipped. Get this down to just a basic network.

well you should be able to set them all to static addresses if you like, but the procedure will vary for each different device.

The procedures will vary but the settings are all the same type, IP address, subnet mask and default gateway. He needs to get a handle on the settings as it sounds like a DHCP problem to me at this point, I don't see how it could be much else as the hardware seems to be working.

I did all of these but disappointment again. is it possible the way I set static ip is wrong ? in order to do that, I write sudo nano /etc/dhcpcd.conf and configure that file. That file includes :

interface eth0
inform 192.168.1.100/24
static routers=192.168.1.100
noipv6

Also to set static ip, it is told to use /etc/network/interfaces command. I use current raspbian. How I should set static ip correctly ?

@RednodeNewbie how did you set a fixed ip address? Did you use the GUI or edit conf files?

Both ways actually but lastly using GUI