If the database is running, probably the database hasn’t registered yet with the listener. This occurs when the database or listener just starts up. To fix, connect as sysdba:

SHOW parameter LOCAL listener

If something or nothing appears, reset it with:

ALTER system SET local_listener='(address=(protocol=tcp)(host=localhost)(port=1521))';
ALTER system register;

At this point test if it’s working fine:

tnsping xe
 
TNS Ping Utility for Linux: Version 11.2.0.2.0 - Production on 26-NOV-2012 17:04:16
 
Copyright (c) 1997, 2011, Oracle.  All rights reserved.
 
Used parameter files:
 
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = XE)))
OK (0 msec)