How to get the node from the url referer?
This method works for me:

use Symfony\Component\HttpFoundation\Request;
use Drupal\Core\Url;
// Getting the referer.
$request = \Drupal::request();
$referer = $request-&gt;headers-&gt;get('referer');
// Getting the base url.
$base_url = Request::createFromGlobals()-&gt;getSchemeAndHttpHost();
// Getting the alias or the relative path.
$alias = substr($referer, strlen($base_url));
// Getting the node.
$params = Url::fromUri("internal:" . $alias)-&gt;getRouteParameters();
$entity_type = key($params);
$node = \Drupal::entityTypeManager()-&gt;getStorage($entity_type)-&gt;load($params[$entity_type]);

//to use dpm you need the devel module
dpm($node-&gt;id());
dpm($node-&gt;title-&gt;value);